Couldn't you return the data you need by using an outer join? The rows in
tbl1 that aren't in tbl2 would have null values in the name fields. You
could order by the name fields.

Or, you could migrate the data to Oracle and use DECODE to put "No record"
in the name fields that are null.   :>)

--Walt

-----Original Message-----
From: Forer, Leif [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 05, 2002 1:58 PM
To: 'DL Neil'; 'Nathan'; [EMAIL PROTECTED]
Subject: RE: SELECT this IF that


DN-

I'm not sure what you mean by "tbl2's population is a sub-set of that
in tbl1".  tbl1 contains user id nums and hours each user spent working on a
project.  tbl2 contains user id nums and the first and last names that
correspond to each user id.  There are user id nums in tbl1 that do not
exist in tbl2 (probably because the users are no longer work here).  Hope
that helps clarify.

The query you suggested is not working the way I hoped it would.  I just
want to select the hours from tbl1 and the first and last name from tbl2
where the user id from tbl1 is the same as the user id from tbl2.  If, the
user id in tbl1 does not exist in tbl2 I want MySQL to return 'no record'.


NATHAN-

Because I'm selecting multiple user ids in the query, some of which exist in
both tables, some of which do not, MySQL only returns the entries that exist
in both tables with a "SELECT tbl1.id, tbl1.data, tbl2.name FROM tbl1, tbl2
WHERE tbl1.id = tbl2.id;"  That means I'm not getting all the data from tbl1
and I need to get all the data from tbl1 whether or not the id # exists in
tbl2.  Hope this helps clarify.



************************************************************************** 
This e-mail and any files transmitted with it may contain privileged or 
confidential information. It is solely for use by the individual for whom 
it is intended, even if addressed incorrectly. If you received this e-mail 
in error, please notify the sender; do not disclose, copy, distribute, or 
take any action in reliance on the contents of this information; and delete 
it from your system. Any other use of this e-mail is prohibited. Thank you 
for your compliance.




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