USING NOT IN will exclude reports that nobody has ... which I'm not sure is
the outcome he was after - It was my first thought as well but the actual
solution (assuming reports someone isn't signed up for includes reports that
nobody is signed up for) is quite simple I think - just change the where
clause to !=

-----Original Message-----

CUT

>   SELECT reports.id,reports.report_name FROM reports LEFT JOIN
> reports_signup ON reports.id = reports_signup.report_id WHERE
> reports_signup.user_id = '2';

You don't need a LEFT JOIN for this.

> I now want to write a query to select the report names of all reports
> a particular user is *not* signed up to - I'm having big troubles with
> this.

> Can anybody assist me?

"NOT IN" sounds always like a LEFT JOIN with IS NULL:

SELECT reports.id, reports.report_name
FROM reports
LEFT JOIN reports_signup ON reports_signup.report_id = reports.id
AND reports_signup.user_id = 2
WHERE reports_signup.user_id IS NULL

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to