Item in two db tables

From: Date: Wed, 04 Apr 2001 15:37:56 +0000
Subject: Item in two db tables
Groups: php.general 
Request: Send a blank email to php-general+get-47075@lists.php.net to get a copy of this message
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 not appear in table 2<BR>"; } // end if } // end while kind regards, bill hollett

« previous php.general (#47075) next »