[英]How to select table in mysql with comparison by 2 rows using value from array?
I have a select query like this one: 我有一个这样的选择查询:
SELECT * FROM `table`
WHERE `is_deleted`!='1' AND
(
(`a`='1' AND `b`='1')
OR
(`a`='2' AND `b`='2')
)
ORDER by `timestamp` DESC LIMIT 0,20
How to make a select query using "IN" operator with comparison rows a
and b
? 如何使用带有比较行
a
和b
“ IN”运算符进行选择查询?
Also you could use in
with several fields at once. 你也可以使用
in
几个领域的一次。
SELECT * FROM `table`
WHERE `is_deleted`!='1'
AND (`a`, `b`) IN ((1,1),(2,2))
ORDER by `timestamp` DESC LIMIT 0,20
It's strange, but there is no description of this behavior in the documentation IN , only a little note in the comments. 这很奇怪,但是在文档IN中没有对此行为的描述,在注释中只有一点点注释。
The IN operator also works with tuples, at least in version 4.1: mysql> select (3,4) in ((2,3),(3,4));
至少在版本4.1中,IN运算符还可以使用元组:mysql> select((2,3),(3,4))中的(3,4);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.