0

有没有办法合并这两个查询?

SELECT * FROM OFF WHERE New = 0 AND Saw = 1 AND El = 0
SELECT * FROM OFF WHERE New = 1 AND Saw = 0 AND El = 0

如果我使用这个查询:

SELECT * FROM OFF WHERE New = 0 AND Saw = 1 AND El = 0 AND New = 1 AND Saw = 0 AND El = 0

我显然有其他预期的结果。

谢谢!

4

2 回答 2

1

OR在对这些条件进行分组时使用,

SELECT * 
FROM   `OFF`
WHERE  (New = 0 AND Saw = 1 AND El = 0) OR 
       (New = 1 AND Saw = 0 AND El = 0)
于 2013-03-17T13:29:09.870 回答
0

您始终可以使用 UNION 合并任意两个查询

(SELECT * FROM OFF WHERE New = 0 AND Saw = 1 AND El = 0)
UNION
(SELECT * FROM OFF WHERE New = 1 AND Saw = 0 AND El = 0)
于 2013-03-17T13:30:13.413 回答