gpt4 book ai didi

php - mysql 查询可以有 2 个内连接和 2 个 IN 子句吗?

转载 作者:行者123 更新时间:2023-11-30 00:19:38 25 4
gpt4 key购买 nike

我有4个不同的mysql表,

SELECT node.created AS node_created, node.nid AS nid, node.title AS title 
FROM node
INNER JOIN field_data_field_resume_education ON field_data_field_resume_education.entity_id = node.nid
INNER JOIN
field_data_field_resume_of_study ON
field_data_field_resume_of_study.entity_id =
field_data_field_resume_education.field_resume_education_value
INNER JOIN
field_data_field_resume_degree_level ON
field_data_field_resume_degree_level.entity_id =
field_data_field_resume_education.field_resume_education_value
WHERE field_data_field_resume_degree_level.field_resume_degree_level_tid IN (4,7)
AND field_data_field_resume_of_study.field_resume_of_study_tid IN (18,19,21)
and (node.status = '1')
AND (node.type IN ('resume_content '))
GROUP BY nid
ORDER BY node_created DESC

我试图从两个不同的表中获取值,以便 IT 仅返回两个表中存在的公共(public)值,但它只返回一个空查询。我检查过两者都有一个共同的nodeid。

where 子句中可以有 2 个 IN 子句条件吗?

请告诉我代码有什么问题。

最佳答案

如果 node.type IN ('resume_content ') 不是问题,则检查其他两个连接以及其中的所有条件,其中之一将失败,如连接 field_data_field_resume_of_study.entity_id = field_data_field_resume_education.field_resume_education_value可能会失败。

您应该执行 select * from one table然后从一个表中选择*加入另一个表然后从一个表中选择 * 连接另一个表连接第三个然后 select * from one table join another join 第三个和 where 条件 1,您将很容易知道它失败的地方......

关于php - mysql 查询可以有 2 个内连接和 2 个 IN 子句吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23340089/

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