我需要执行MySQL查询类
select * from table where id = 1 or id = 2 or id = 3 or id = 4 or id = 5 or id = 6
是否有任何表达式来减少sql对值进行分组?,比如
select * from table where id oneof (1,2,3,4,5,6)
我和and and和...有相同的问题。
答案 0 :(得分:2)
是的,您需要使用in
功能。
select * from table where id in (1,2,3,4,5,6)
http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_in