我已经从php-MySQL中的几个sql短语中得到了结果。我的$sql1和结果查询短语如下所示。
$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函数。请给我一个建议。谢谢您的关心。
发布于 2014-02-20 16:54:44
用PHP做这件事将是致命的,并且是高度的资源消耗。如果您只是在要交集的键字段上使用as条件在所有大型查询之间进行内连接,那么您将直接获得您要查找的交集。
另一件事,可能什么都没有显示,因为你没有抛出任何错误到屏幕上,检查你的系统和应用程序中的PHP错误配置,以便在开发时启用它们。
https://stackoverflow.com/questions/21899119
复制相似问题