条件查询

select * from  TbStudent where tsclassId = 3 or tsclassId = 4 or tsclassId = 5

select * from TbStudent where tsclassId in(3,4,5)--可以用in替代or
--查询班级ID为3,4,5的学生


--对于in或者or查询如果查询的是连续的几个数字最好使用>=或<= 或者between.....and.....不要用or或in
select * from TbStudent wherre tsclassId>=3 and tsclassId<=5
select * from Mystudent where fage>=20 and fage <=30 and fgender = '男'
select * from Mystudent where fage between 20 and 30 and fgender = '男'
--查询年龄在20-30岁之间的男学生(包含20和30),两张效果都一样

猜你喜欢

转载自blog.csdn.net/ABC13222880223/article/details/81842690