MySQL 条件查询

MySQL About 490 words

where 子句

select * from 表名 where 条件;
Copy

比较运算符

等于=
大于>
大于等于>=
小于<
小于等于<=
不等于!=<>
Copy

逻辑运算符

and
or
not
Copy

模糊查询

like
%表示任意多个任意字符
_表示一个任意字符
Copy

范围查询

in表示在一个非连续的范围内
select * from user where home in ('魏','蜀');

between ... and ...表示在一个连续的范围内 ,>= and <=
select * from user where age between 26 and 40;
Copy

空判断

注意:null''是不同的
判空is null

select * from user where home is null;

判非空is not null
select * from user where home is not null;
Copy

优先级

小括号,not,比较运算符,逻辑运算符
andor先运算,如果同时出现并希望先算or,需要结合()使用
Copy
Views: 1,777 · Posted: 2019-04-06

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh