Mysql-条件查询

-- 条件查询
-- 比较运算符
-- select …… from 表名 where ……

-- >
-- 查询身高大于180的信息
select * from student where high>180.00; 

-- <
-- 查询身高小于180的信息
select * from student where high<180;

-- >=
-- <=
-- 查询大于或者等于188.88的信息
select * from student where high=188.88; 


-- =
-- 查询性别为男的所有学生的名字
select name from student where gender=1;

-- != 或者 <>
select * from student where high!=188.88;
select * from student where high<>188.88;


-- 逻辑运算符
-- and
-- 160至190之间的所有学生信息
select * from student where high>160 and high<190;
select * from student where 160>high<190;(答案有误)

-- 18岁以上的女性
select * from student where age>18 and gender=2;


-- or
-- 18以上的身高高过188.88(包含)以上
select * from student where age>18 or high>=188.88;

-- not
-- 不再18岁以上的男性 这个范围内的信息
select * from student where not (age>18 and gender=1);

 

表取自:

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

posted on 2023-02-01 13:30  夜黎i  阅读(27)  评论(0)    收藏  举报

导航