MySQL中的WHERE子句

来源:互联网 发布:cr173破解软件 编辑:程序博客网 时间:2024/05/21 12:45

where子句中的运算符:

    <,>,=,!=,>=,<=,in(),between""and"",and,not,or,like

1、其中 <,>,=,!=,>=,<=,in(),between and 属于比较运算符

       in(A,B):表示包含A和B的结果

between 1 and 5 :会查出在1和5之间的值包括1和5

2、and,not,or属于逻辑运算符

select * from user where age>4 and age <14 : 查询的出来的结果集中的age处于4和14之间,不包括4和14

select * from user where age>4 or age <3 : 查询的出来的结果集中的age有大于4的也有小于3的,不包括4和3

select * from user where not age>4 :查询的出来的结果集中的age没有大于4,可以等于4

3、、like是模糊查询

select * from user where phone like '130%' 查询出user表中phone为130开头的用户

select * from user where phone like '130_' 查询出user表中phone为130开头后面只有一位的用户,比如1301

select * from user where phone like '%130%' 查询出user表中phone中含有130的用户

select * from user where phone like '%130'查询出user表中phone为130结尾的用户

%为通配符,不限定位数

_也是通配符,一个表示一位

1 0
原创粉丝点击