简单的数据查询
2016-01-09 00:24
309 查看
简单的数据查询
简单的查询语句
select * from
投影操作
seleact 列1,列2 from 表名
列名列表几种书写方式:
1.如果我们选择某个表中的多个列,那么列名之间用逗号分隔开;
2.如果是单个列,只需要列出该列的列名即可;
3.如果选择所有的列,可以简单的用“*”号带代替列名列表。
如何查询
select 姓名,年龄 from t_student
表前缀:
select t_student.(要操作哪一个表的表名)姓名 from t_stuent
列别名
select concat(t_name,'_',t_address)AS'公司名字和地址' from gongsi;其中AS可以省略
计算列
列如:将每个学生年龄加十
select 年龄(t_age)+10 from 表名
排除重复数据
select distinct 列 from 表
选择操作(where ,limit)
返回限定行数的查询
控制返回的行:select * from gongsi where t_id>=2 and t_id<=3;
select * from gongsi LIMIT 2;从0开始 有前2条(limit序号是从0开始的)
选择操作(where)
查询公司在绵阳的:select * from gongsi where t_address='绵阳';
执行范围测试(between and)
select * from 列1 where 列2 between 12 and 20;(包含12和20)
查询集合
select * from yuangong where t_age in[not in(不等于)](18,19,20);
模糊查询(like)
select * from yuangong where t_name like '王%'(表示以王开头的)
[‘%青’(表示以青结尾的)]
‘__’(表示为两个字的)
‘x%n_’(表示以x开始倒数第二为n的)
简单的查询语句
select * from
投影操作
seleact 列1,列2 from 表名
列名列表几种书写方式:
1.如果我们选择某个表中的多个列,那么列名之间用逗号分隔开;
2.如果是单个列,只需要列出该列的列名即可;
3.如果选择所有的列,可以简单的用“*”号带代替列名列表。
如何查询
select 姓名,年龄 from t_student
表前缀:
select t_student.(要操作哪一个表的表名)姓名 from t_stuent
列别名
select concat(t_name,'_',t_address)AS'公司名字和地址' from gongsi;其中AS可以省略
计算列
列如:将每个学生年龄加十
select 年龄(t_age)+10 from 表名
排除重复数据
select distinct 列 from 表
选择操作(where ,limit)
返回限定行数的查询
控制返回的行:select * from gongsi where t_id>=2 and t_id<=3;
select * from gongsi LIMIT 2;从0开始 有前2条(limit序号是从0开始的)
选择操作(where)
查询公司在绵阳的:select * from gongsi where t_address='绵阳';
执行范围测试(between and)
select * from 列1 where 列2 between 12 and 20;(包含12和20)
查询集合
select * from yuangong where t_age in[not in(不等于)](18,19,20);
模糊查询(like)
select * from yuangong where t_name like '王%'(表示以王开头的)
[‘%青’(表示以青结尾的)]
‘__’(表示为两个字的)
‘x%n_’(表示以x开始倒数第二为n的)
相关文章推荐
- lvs之keepalived
- Quartz2D---苹果官方的⼆维绘图引擎(绘制基本图形)
- iOS中int,float怎么保存在NSMutableArray中
- LVS之DR模式
- adb命令集合
- java集合框架中的数据结构
- 设计模式里的多态,答疑
- docker入门与hadoop
- nagios插件之监控文件更新时间
- LVS之NAT模式
- 【视频】Excel2013十大企业级明星函数视频课程【精讲】
- 2016/1/9 冒泡排序法 预习
- python之三层菜单递归
- ASIHTTPRequest 提示#import <libxml/HTMLparser.h>找不到
- Android media媒体库分析之:MediaProvider
- 千里码第一题
- POJ 3279 - Fliptile
- WebForms UnobtrusiveValidationMode 需要“jquery”ScriptResourceMapping
- iOS NSUserDefaults
- 使用 Navicat111_premium 将 oracle 数据库迁移到 mysql