mysql条件查询与通配符

查询结果过滤

select 列名 from 表名 where 列满足的条件

order by 应该在where 后

where子句使用操作符

字符需要引号引住

= 等于

<>不等于

!=不等于

<  小于

<= 小于等于

>  大于

>=  大于等于

is null   为空

is not null  不为空

binary区分大小写 写在where后

between   在指定的两个值之间包含边界值  between  a and b

and  同时满足条件

select 列名 from 表 where 列1满足条件 and 列2满足条件

or   满足其中一个

select 列名 from 表 where 列1满足条件 or(或者) 列2满足条件

and 优先级高于or  可以使用()把条件分组

in操作符

在括号中的范围 括号内可以包含select语句

select 列 from 表 where 列 in(value1,value2);

not操作符 

不在括号范围内  只支持对in between和exists子句取反

select 列 from 表 where 列 not in(value1,value2);

like操作符

通配符 %表示任何字符出现任意次数 不匹配null     like '%.5'   可以匹配 .5

通配符 _  匹配一个字符包含空格必须有

not like 与like取反

 

posted @ 2020-08-16 21:35  寂静音无  阅读(623)  评论(0)    收藏  举报