looping through values using IN (val1, val2,...
Posted: Tue Sep 13, 2011 8:49 am
Hi, can anyone help:
This code only returns me the first 2 result sets - one from each table. I can't get it to loop. Some of these numbers are found in id in office and some of them in details but they should all be there from one or the other table. grateful for any help.
This code only returns me the first 2 result sets - one from each table. I can't get it to loop. Some of these numbers are found in id in office and some of them in details but they should all be there from one or the other table. grateful for any help.
Code: Select all
$query9 = "SELECT id FROM details WHERE id IN ('73','20','39','41','48','50','71','72') UNION SELECT id FROM office WHERE id IN ('73','20','39','41','48','50','71','72') AND id NOT IN (SELECT id FROM details);";
$result9 = mysql_query($query9, $recommendingpeople) or die(mysql_error());
$row9 = mysql_fetch_array($result9);
do {
echo $row9['id'];
} while ($row9 = mysql_fetch_assoc($result9));
$rows = mysql_num_rows($result9);
if($rows > 0) {
mysql_data_seek($result9, 0);
$row9 = mysql_fetch_assoc($result9);
}