简体   繁体   中英

Can mysql query have 2 inner join with 2 IN clause?

I have 4 different mysql table,

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

Iam trying to get values from 2 different tables such that IT returns only the common values present in both, But it just returns an empty query. I have checked that both have a common nodeid.

Can we have 2 IN clause conditions in the where clause.

Please can any tell me what`s wrong with the code.

If node.type IN ('resume_content ') is not the issue then check othet two joins and all condition in where, one of these will be failing like join field_data_field_resume_of_study.entity_id = field_data_field_resume_education.field_resume_education_value can fail.

You should execute select * from one table then select * from one table join another then select * from one table join another join 3rd then select * from one table join another join 3rd and where condition 1, you will easily cam to know where its failing...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM