Reputation: 627
I would like to do a multiple select in mysql but have not had any joy. I have tried following examples on here and around the web but they do not seam to fit what I am trying to do.
My select statement is as follows
SELECT a.* FROM Calendar a
WHERE a.CalendarId = 256 AND a.Private = 0
UNION
SELECT b.* FROM Calendar b
WHERE b.CalendarId = 256 AND b.Private = 1 AND b.PrivateId = 11
To explain what I want above, I would like to return all Calendar rows that have a Private value of 0.
I would also like to filter this by selecting only those that have Private = 1
that have the PrivateId = 11
(in this example).
Thanks
Upvotes: 0
Views: 74
Reputation: 16351
Try :
SELECT *
FROM Calendar
WHERE CalendarId = 256
AND (Private = 0 OR (Private = 1 AND PrivateId = 11))
Upvotes: 3