我想从mysql中的4个表中检索记录 - 是否有任何替代方法 - 此查询返回所有记录

时间:2017-04-29 09:38:49

标签: sql mysqli

SELECT * FROM inquiry e,sales_lead sl,customer c,project p where((e.customer_id = c.customer_id和e.project_id = p.project_id)或e.sales_lead_id = sl.sales_lead_id)和e.delete_status<大于1

1 个答案:

答案 0 :(得分:0)

使用以下JOIN查询:

SELECT * FROM enquiry e
LEFT OUTER JOIN sales_lead sl ON e.sales_lead_id=sl.sales_lead_id
LEFT OUTER JOIN customer c ON e.customer_id=c.customer_id
LEFT OUTER JOIN project p ON e.project_id = p.project_id
WHERE e.delete_status <> 1