我的腳本滿足要求,但因爲這個原因觸發了幾千個查詢,所以需要50-65秒。我正在尋找替代,更優雅和快速的解決方案。php MySQL獲取字符串之間的差異
SELECT GROUP_CONCAT(DISTINCT BatchNo SEPARATOR ', ') AS picklists, web_company_name
FROM PickBatch
LEFT JOIN customer_master ON customer_master.VC_CUSTOMER_CODE = PickBatch.Customer
GROUP BY Customer
這將返回列選項列表像4334,3443,3341,4543
之後,我必須把它逐個對比4334,3443的另一列
while($row=mysql_fetch_array($res))
{
$picklists = explode(', ', $row['picklists']);
$pickString = '';
foreach($picklists as $batch)
{
//invoiced
$sql2 = "SELECT invoice_no FROM invoice_web_order WHERE FIND_IN_SET('$batch', frombatch) LIMIT 1";
$res2 = mysql_query($sql2) or die(mysql_error());
if (mysql_num_rows($res2) > 0)
{
continue;
}
$pickString .= "$batch, ";
}
echo $pickString;
}
因此,例如比較例如,來自「frombatch」的3892,4890,3341,2389將排除3343.
有沒有其他方法可以做同樣的事情?那麼只有4334,3443,4543會被退回?
當你說「將排除3343」。你的意思是「會排除3341」嗎? –