gpt4 book ai didi

mysql - PHP 查询不起作用

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

这正在工作:

SELECT *
FROM ((((defect
JOIN project_testcase ON
defect.Test_Id=project_testcase.Test_Id)
JOIN testcase ON
defect.Test_Id=testcase.Test_Id)
JOIN project_pm ON
project_testcase.Project_Id=project_pm.Project_Id)
JOIN employee ON
employee.Emp_id=project_pm.Emp_id)

但是,这不起作用:

SELECT *
FROM ((((defect
JOIN project_testcase ON
defect.Test_Id=project_testcase.Test_Id)
JOIN testcase ON
defect.Test_Id=testcase.Test_Id)
JOIN project_pm ON
project_testcase.Project_Id=project_pm.Project_Id)
JOIN employee ON
employee.Emp_id=project_pm.Emp_id)
WHERE Project_Id LIKE '%$categ%'

因为我使用了 JOIN 表并使用 Project_Id 进行连接。这是错误吗?

最佳答案

要解决此问题,我要做的第一件事是将其粘贴到 SQL 格式化程序中。这将有助于查找语法错误并可以帮助您查看逻辑错误。我会推荐freeformatter.com .

其次,你可以去掉括号。

修复

您需要指定在 WHERE 中获取 Project_Id 的表,因为它位于多个表中,但为了清楚起见,我将始终指定它来自哪个表。

select
*
from
defect
join
project_testcase
on defect.Test_Id=project_testcase.Test_Id
join
testcase
on defect.Test_Id=testcase.Test_Id
join
project_pm
on project_testcase.Project_Id=project_pm.Project_Id
join
employee
on employee.Emp_id=project_pm.Emp_id
where
project_testcase.Project_Id like '%$categ%'

关于mysql - PHP 查询不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36696986/

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