数据库基本语句(4)

between…and…等in集合等、&&、||等!等)
一、例如查询年龄大于二十岁的(默认student表):select *from student where age >20;
注:等于条件只用一个“=”,不等于条件的两种写法:“!=、<>”
二、查询年龄大于等于20小于等于30
select *from student where age>=20 and age<=30(比较麻烦)
select *from student where age between 20 and 30;(推荐)
三、查询22岁、19岁、25岁的信息
select *from student where age=22 or age=19 or age=25(比较麻烦)
select *from student where in(22,19,25)(比较方便)
查询某样数据为空
select *from student where x=null;(错误写法,null不能使用=或者!=判断)
select *from student where x is null;查询不为null(is not null)

猜你喜欢

转载自blog.csdn.net/m0_46217913/article/details/104063528