当前位置: 移动技术网 > IT编程>数据库>Mysql > MySQL第六课

MySQL第六课

2020年01月03日  | 移动技术网IT编程  | 我要评论

select [distinct]     * /{字段名1,字段名2,字段名3,.........}

from 表名

[where 条件表达式1]

[group by 字段名[having 条件表达式2]]

[order by 字段名[asc/desc]]

[limit[offset] 记录数];

 

distinct:去掉重复的值

group by :分组

order by :排序

 

 

带有in 关键字的查询:

select   */字段名

from 表名

where 字段名 [not] in(元素1,元素2,.....);

 

带有between and 关键字的查询:

select */{字段名}

from 表名 where 字段名[not] between 值1and 值2;

 

空值查询:

select  */字段名

from 表名   where 字段名 is [not] null;

 

带distinct 的查询:

select distinct 字段名 from 表名;

如果作用多个字段,完全重复才会被删去。

 

带like 关键字的查询:

select  */字段名

from 表名

where 字段名 [not]  like '匹配字符串'

通配符:1.%,可以匹配任意长度的字符串,包括空字符串

's%'以字符s开头的

2._下划线通配符,可以匹配任意长度的字符串,包括空字符串

"\%"匹配百分号字面值

 

带and关键字的多条件字查询:

select   */字段名

from 表名

where 条件表达式/and条件表达式[...and条件表达式n]

 

带or关键字的查询:

select  */字段名

from 表名

where 条件表达式/or 条件表达式2[...or 条件表达式n];

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网