Ack .. ignore the part of my last post re the original query not working :)
... it will as the user_id column will be null for reports notbody has and
this will fail the where clause .... my mistake. the LEFT join is redundant,
however, and the replacement I posted will also work ...

Anyway - have fun

-----Original Message-----
From: Peter Hicks [mailto:[EMAIL PROTECTED]]
Sent: Sunday, 17 March 2002 9:28 PM
To: [EMAIL PROTECTED]
Subject: Emulating a subselect


Hi everyone

Maybe somebody can help me with what seems like a tricky
subselect-avoidance question?

In a MySQL database, there are two tables - 'reports' and
'reports_signup'.   'reports' has two columns, 'id' and 'report_name'.
 'reports_signup' has three columns - 'id', 'report_id' and 'user_id'.
 ('id' in this table may be superfluous).  'report_id' is a value from
the 'reports_table', and 'user_id' is a value from another table.

I've written a query to select the report names of all reports a
particular user (say, id '2') is signed up to:

  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';

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?

Best wishes,


Peter.



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