Reputation: 69
I have the following table:
| id | market | source | event |
+----+--------+--------+-------+
| 1 | 1 | 1 | 1 |
| 2 | 1 | 2 | 1 |
| 3 | 2 | 1 | 1 |
| 4 | 3 | 1 | 2 |
| 5 | 1 | 3 | 1 |
I want to be able to select rows where (market = 1 AND event = 1) and also where (market = 3 AND event = 2). Can someone point me in the right direction?
Upvotes: 1
Views: 31
Reputation: 57640
where (market = 1 AND event = 1) ALSO where (market = 3 AND event = 2) above can be converted to
WHERE (market = 1 AND event = 1) OR (market = 3 AND event = 2)
Upvotes: 1
Reputation: 69440
This should be the select you need:
select * from `table` where (market = 1 AND event = 1) or (market = 3 AND event = 2)
Upvotes: 1
Reputation: 29051
Try this:
SELECT source
FROM tableA
WHERE (market = 1 AND event = 1) OR
(market = 3 AND event = 2)
GROUP BY source
HAVING COUNT(1) = 2;
Upvotes: 0
Reputation: 465
Replace t_table with your table name here:
Select * from t_table where (market = 1 and event = 1) or (market = 3 and event = 2)
Upvotes: 0