I'm performing a query on 2 tables: mysql> SELECT log.id, SUM (log.hours), empnum.lname > FROM log, empnum > WHERE log.id = '26009' > AND log.id=empnum.id > GROUP BY hours; Empty set (0.01 sec)
The log table contains id numbers (plus a bunch of other data) but no corresponding names. The name are all stored in the empnum table. The problem is, there are instances where the id exists in the log table but not in the empnum table. In this case, MySQL returns and empty set. My question is: how can I still get MySQL to return all the info from the log table when it doesn't find a corresponding id entry in the empnum table? Can I use an "if" statement somehow? Here's a query of the same id number but performed on just the log table (to prove that there is an id entry in the log table but not the empnum table): mysql> SELECT log.id, SUM (log.hours) FROM log WHERE log.id = '26009' GROUP BY id; +-------+----------------+ | id | sum(log.hours) | +-------+----------------+ | 26009 | 619.0 | +-------+----------------+ 1 row in set (0.00 sec) ************************************************************************** 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