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);
表取自:
浙公网安备 33010602011771号