select [distinct] * |{字段名列表} ---查询from 表名
[where 条件
[group by 字段名 [having 条件]] ---分组
[order by 字段名 [asc|desc]] ---排序[升序/降序]
[limit [offset]记录数] ---分页
常见关系运算符: = <> != > < <= >=
select * | 字段名1,字段名2...字段名N from 表名 where 字段名 [not] in (元素1,元素2,...)
in:在…里面
not int:不在…里面
select * | 字段名1,字段名2...字段名Nfrom 表名 where 字段名 [not] between 值1 and 值2
between…and:表示一个范围
select * | 字段名1,字段名2...字段名Nfrom 表名 where 字段名 is [not] null is null:值是否为空,
不能写成:= null is not null :值是否不为空,
不能写成:!=null
distinct关键字用于去掉重复的记录
select distinct * from 表 [where 条件]
select * | 字段名1,字段名2...字段名N from 表名 where 字段名 [not] like ‘匹配字符串’;
通配符 _ 代表一个字符
% 代表一个字符串
[]范围
[^]非范围内
逻辑与,多个条件要同时成立
select * | 字段名1,字段名2...字段名Nfrom 表名 where 条件1 and 条件2;
逻辑或,多个条件中只要成立一个即可
select * | 字段名1,字段名2...字段名Nfrom 表名 where 条件1 or 条件2;
select 字段名 as 别名 from 表名 别名; select 字段名 别名 from 表名 别名;
浙公网安备 33010602011771号