MySQL JOIN problem
| From: | Rob Day | Date: | Tue, 11 Mar 2003 22:28:56 +0000 |
| Subject: | MySQL JOIN problem | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-26259@lists.php.net to get a copy of this message | ||
I'm having trouble getting the results I want. The database deals with
libraries and reports they've submitted. Here are the relevant tables with
the primary keys marked with a star (*):
+--------------+
| libinfo |
+--------------+
| lib_id* |
| lib_name |
| city |
+--------------+
+---------------+
| reportinfo |
+---------------+
| report_id* |
| lib_id |
| exclude |
| quarter |
+---------------+
In reportinfo.quarter there are currently two possible values, 0 and 2. I
want libinfo.lib_name and libinfo.city for all entries in libinfo, where
libinfo.lib_id = reportinfo.lib_id, that do not have an entry in reportinfo
where reportinfo.quarter = 0. I don't care if there is an entry in
reportinfo where quarter = 2. Can someone please help me construct this
query? Thanks.
-Rob
P.S. I realize that this question has nothing to do with PHP. But be assured
that this is one small part of a PHP/MySQL web application. Thank you for
your indulgence.