我有下表:
| id | market | source | event |
+----+--------+--------+-------+
| 1 | 1 | 1 | 1 |
| 2 | 1 | 2 | 1 |
| 3 | 2 | 1 | 1 |
| 4 | 3 | 1 | 2 |
| 5 | 1 | 3 | 1 |
我希望能够选择行(market = 1 AND event = 1)以及where(market = 3 AND event = 2)的行。有人能指出我正确的方向吗?
答案 0 :(得分:1)
这应该是你需要的选择:
select * from `table` where (market = 1 AND event = 1) or (market = 3 AND event = 2)
答案 1 :(得分:1)
where(market = 1 AND event = 1)ALSO where(market = 3 AND event = 2) 以上可以转换为
WHERE (market = 1 AND event = 1) OR (market = 3 AND event = 2)
答案 2 :(得分:0)
将t_table替换为您的表名:
Select * from t_table where (market = 1 and event = 1) or (market = 3 and event = 2)
答案 3 :(得分:0)
试试这个:
SELECT source
FROM tableA
WHERE (market = 1 AND event = 1) OR
(market = 3 AND event = 2)
GROUP BY source
HAVING COUNT(1) = 2;