Re: Item in two db tables
| From: | Wizaerd) | Date: | Wed, 04 Apr 2001 15:47:46 +0000 |
| Subject: | Re: Item in two db tables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-47080@lists.php.net to get a copy of this message | ||
I'm not 100% certain about this, but I believe you want to look at using a LEFT OUTER JOIN
At 11:37 AM 4/4/01 -0400, bill wrote:
If I want to find a list of items in one table whose id does not appear in another table, can that be done in one query? I can only figure it out if I use two queries. $result=mysql_query("SELECT id,item FROM table1"); while ($row=mysql_fetch_array($result)) {$thisid=$row["id"]; $thisitem=$row["item"]; $ckresult=mysql_query("SELECT id FROM table2 WHERE id=$thisid"); if (!mysql_num_rows($ckresult)) { echo "$thisitem using id $thisid is in table 1 but does notappear in table 2<BR>";} // end if} // end while kind regards, bill hollett -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net