Take the 2-minute tour ×

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
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).


share|improve this question
I think you want an INTERSECTION not a UNION... –  lc. Jan 22 '13 at 16:08
what's the difference between what you expected and the real example you tired –  Hitman47 Jan 22 '13 at 16:10
@Hitman47 I was trying to use JOIN –  A Star Jan 22 '13 at 16:14
add comment

1 Answer

up vote 3 down vote accepted

Try :

FROM Calendar
WHERE CalendarId = 256
    AND (Private = 0 OR (Private = 1 AND PrivateId = 11))
share|improve this answer
new format made it even worse :) I'd keep it 2-liner but move CalendarId into first line –  Your Common Sense Jan 22 '13 at 16:10
This is perfect thank you! I guess I was trying to overcomplicate it. –  A Star Jan 22 '13 at 16:13
add comment

Your Answer


