0
我已經從php-MySQL中的幾個sql短語中得到了結果。 我的$ sql1和結果查詢短語如下所示。我應該如何在php中使用array_intersect函數而不是MySQL交集?
$sql1= "SELECT code_co.code, code_co.disease_co, code_en.disease_en, ds.ds_url
FROM code_co
LEFT JOIN code_en ON code_en.code = code_co.code
LEFT JOIN note ON note.code = code_co.code
...
where condition
$result1= mysqli_query($con,$sql1);
但我有9個SQL查詢短語,就像上面的代碼。在9 sql查詢中選定的列是相同的。那就是
$sql2= "SELECT code_co.code, code_co.disease_co, code_en.disease_en, ds.ds_url
FROM code_co
LEFT JOIN code_en ON code_en.code = code_co.code
LEFT JOIN note ON note.code = code_co.code
...
where condition
$result2= mysqli_query($con,$sql2);
...
$sql9= "SELECT code_co.code, code_co.disease_co, code_en.disease_en, ds.ds_url
FROM code_co
LEFT JOIN code_en ON code_en.code = code_co.code
LEFT JOIN note ON note.code = code_co.code
...
where condition
$result9= mysqli_query($con,$sql9);
最後我想得到9個結果的交集,但不支持MySQL。 所以我想通過php代碼來解決這個問題。 這是array_intersect()函數。 但我不知道如何使用它。
while($row1= mysqli_fetch_array($result1))
while($row2= mysqli_fetch_array($result2))
....
while($row9= mysqli_fetch_array($result9))
$intersect = array_intersect($row1, $row2, $row3, $row4, ...., $row9);
print_r($intersect);
mysqli_close($con);
?>
沒有錯誤信息,但沒有顯示任何內容。 我首先在這段代碼中使用了array_intersect函數。 請給我一個建議。 謝謝你的關注。
謝謝你的忠告! – Drohjho