sql 查询语句 where 后面如果加多个条件

select * from 表 where 编号=1 2 3 4
请问可以在=号后面加多个条件吗?可以的话语法是怎样的,还有如果不行要用什么别的办法实现呢?

where后加多个条件可以用and来连接。

如,student表中有如下数据:

现在要查,sex为男,age为20的那些数据,可用如下语句:

select * from student where sex='男' and age=20;

结果截图:

温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-10-11
select * from 表 where 编号 in (1,2,3,4)

或者

select * from 表 where 编号=1 or 编号=2 or 编号=3 or 编号=4

或者

select * from 表 where 编号=1
union
select * from 表 where 编号=2
union
select * from 表 where 编号=3
union
select * from 表 where 编号=4

这三个会返回一样的结果
第2个回答  推荐于2017-10-06
select * from 表 where 编号 in (1,2,3,4)

或者

select * from 表 where 编号=1 or 编号=2 or 编号=3 or 编号=4

这两个是同样的道理本回答被提问者采纳
第3个回答  2009-10-11
in或者between等等!
第4个回答  2019-09-12

where条件查询

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网