php mysql 查询我有多个链接表 - 我还有一个表,只有在某些条件存在时才会创建和输入,所以我想将它添加到我的查询中,以避免必须通过数千次查询搜索来寻找这种特殊情况
这是我当前的查询
$query = "SELECT a.UUID FROM contract a
INNER JOIN geoPoint b ON a.customer_UUID = b.customerUUID
WHERE b.garcom_UUID = '$garbCom'
AND b.city_UUID = '$city'";
然后,我检查退回的每件物品(以千计)
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$sentdata = getothertable($row['UUID']); //checks if the item is in the table
$sent = $sentdata ['senttoGarcom'];
if($sent == 0) //if it wasn't found add it to my list
{
array_push($Contracts,$row['UUID']);
}
}
而不是我只想让它成为一个查询 - 伪代码是这样的
$query = "SELECT a.UUID FROM contract a
INNER JOIN geoPoint b ON a.customer_UUID = b.customerUUID
INNER JOIN contract_sales c ON a.UUID = c.contractUUID
WHERE b.garcom_UUID = '$garbCom'
AND b.city_UUID = '$city' AND c.DOESNOTEXIST";
这样我就不必退回数千我只会退回尚未在contract_sales表中的少数几个,我可以继续我的业务......
感谢任何帮助!