I appreciate the help! Actually with a small tweak (had to change the Join complete=0 to complete=1 so I'd only get the tasks that were completed) it appears to be working! Thanks again!
Jason -----Original Message----- From: Roger Baklund [mailto:[EMAIL PROTECTED] Sent: Thursday, August 14, 2003 2:58 PM To: [EMAIL PROTECTED] Cc: Landers, Jason Subject: Re: Subquery IN+SELECT blues * Landers, Jason > I have two tables, meetings and tasks. In the meetings table I > have meeting information and a meeting index called id. In the > tasks table I have task information that is associated with various > meetings. In the tasks table I have a meetingid column that > corresponds with the id in the meetings table. > There is also a boolean column called complete which marks the > task complete or not. > > What I want to do is display only the meetings for which there > are no tasks, and for which all tasks have been completed. To > show the meetings with no tasks here's what I worked up: > > SELECT meetings.* FROM meetings LEFT JOIN tasks ON > meetings.id=tasks.meetingid WHERE tasks.meetingid IS NULL > > But that shows only the meetings for which there are no tasks. Ideally I > would have something like: > > SELECT * FROM meetings WHERE id NOT IN (SELECT meetingid FROM tasks WHERE > complete=0) How about this: SELECT meetings.* FROM meetings LEFT JOIN tasks ON meetings.id=tasks.meetingid AND tasks.complete = 0 WHERE tasks.meetingid IS NULL This will list all meetings except those who have any tasks record with complete=0. That should include those who have complete=1 on all tasks, and those who have no tasks. HTH, -- Roger -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]