如何在php中使用array_intersect函数而不是MySQL intersect?
我已经从php MySQL中的几个sql短语中得到了结果。 我的$sql1和结果查询短语如下所示如何在php中使用array_intersect函数而不是MySQL intersect?,php,mysql,Php,Mysql,我已经从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 c
$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函数。
请给我一个建议。
感谢您的关注。使用PHP将是一个致命的资源消耗者。如果您只是在所有大查询之间使用as条件在您想要相交的键字段上进行内部连接,那么您将直接获得您要查找的相交
另外,可能没有显示任何内容,因为您没有向屏幕抛出任何错误,请检查系统和应用程序中的PHP错误配置,以便在开发时启用它们 谢谢你的忠告!!