这是我目前的查询:
SELECT * FROM users
WHERE blah blah...
AND users.who = '1'
AND users.seeking = '2'
OR users.seeking = '5'
OR users.seeking = '8'
OR users.seeking = '9'
OR users.seeking = '11'
OR users.seeking = '13'
OR users.seeking = '14'
OR users.seeking = '15'
AND users.account_status = '1';
如您所见,搜索字段可以包含多个值。而不是编写这么多OR,是否有一种更漂亮的方法来指定该字段的所有可接受的值,以便由我的select语句返回?
答案 0 :(得分:11)
SELECT * FROM users
WHERE blah blah...
AND users.who = '1'
AND users.seeking IN('2','5','8','9','11','13','14','15')
AND users.account_status = '1';