mysql比较运算,逻辑运算,范围查询,模糊查询

比较运算 > < =  !=  <>   <=  >= 
逻辑运算  and  or  not
范围查询  in  
模糊查询  like
                                                                                                
select distinct age from classes;                                 将classes表格里age去重                          
select * from classes where id <= 3;                               打印classes表格里id<=3的数据  (<>、!=)除了整形还可以用于datetime                       
select * from classes where num is(not) null;                   打印classes表格里num栏是(否)为null       is 和 not 只能用来判断null                        
select * from student where add_time between '2018-05-08' and '2018-05-10 09:00:00';        打印student表格里add_time栏里时间在两者之间的数据,between and相当于>=、<=可作用于时间和整形                               
select name from student where id > 1 and id < 3;        打印student表格里id>1并<3的name栏   and or not 逻辑运算符                             
 select * from student where name like '小%';             模糊查找 like 打印student表格里姓名栏(字段)里以'小'开头的数据 
select * from student where name like '%张%';                     
select * from student where name like '_明';                 占位匹配  _  一个下划线代表一个字符                            
 select * from student where id (not) in (1,2,3);               打印student表格里id是(否)在(1,2,3)里的数据,是否在范围内                             
 

猜你喜欢

转载自www.cnblogs.com/sunzhiqi/p/10072669.html