Mysql-范围查询

-- 范围查询
-- in(1,3,8)表示再一个非连续的范围内
-- 查询 年龄为18,20的姓名
select name from student where age=18 or age=20;
select name from student where age in(18,20);

-- not in 不非连续的范围之类
-- 年龄不是18,20的信息
select * from student where age not in(18,20);

-- between……and……表示再一个连续的范围内
-- 查询 年龄再18到50之间的信息
select * from student where age between 18 and 50; 

-- not between……and……表示不再一个连续的范围内
-- 查询 年龄不在在18到50之间的信息
select * from student where age not between 18 and 50; 


-- 空判断
-- 判空is null
-- 查询身高为空的信息
select * from student where high is null;

-- 判非空is not null

 

 

表取自:

Mysql-几张供于学习的表 - 夜黎i - 博客园 (cnblogs.com)

posted on 2023-02-01 11:21  夜黎i  阅读(84)  评论(0)    收藏  举报

导航