Reputation: 737
I need to execute a MySQL query kind of
select * from table where id = 1 or id = 2 or id = 3 or id = 4 or id = 5 or id = 6
Is there any expression to reduce the sql grouping the values?, something like
select * from table where id oneof (1,2,3,4,5,6)
I have the same question for and and and and ...
Upvotes: 0
Views: 75
Reputation: 44844
Yes you need to use in
function.
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
Upvotes: 2