gpt4 book ai didi

php - “未知表”,尽管它确实存在

转载 作者:行者123 更新时间:2023-11-29 09:18:47 24 4
gpt4 key购买 nike

$query = mysql_query("SELECT company.*, factory.*
FROM company
FULL JOIN factory
ON company.n_id = factory.n_id
WHERE company.n_id = '$n_id' AND factory.n_id = '$n_id'") or die(mysql_error());


在上面你可以看到我的查询。它给我未知表'公司'错误,但公司表100%存在。我错过了什么?

编辑:当我使用右连接或左连接而不是完全连接时,它可以工作......但我需要完全连接。天哪,我会开枪射杀某人。

最佳答案

MySQL 中没有 FULL OUTER JOIN - 请参阅 this link for how to get the functionality .

$query = mysql_query("     SELECT * FROM COMPANY c
LEFT JOIN FACTORY f ON f.n_id = c.n_id
UNION ALL
SELECT * FROM COMPANY c
RIGHT JOIN FACTORY f ON f.n_id = c.n_id
WHERE c.? IS NULL
AND c.n_id = mysql_real_escape_string($n_id)
AND f.n_id = mysql_real_escape_string($n_id)") or die(mysql_error());

您需要将 ? 更新为 COMPANY 表中的列名称,而不是 n_id

关于php - “未知表”,尽管它确实存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3080241/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com