我目前有:
SELECT * FROM submissions AS s
LEFT JOIN submission_category AS sc ON s.submission_category = sc.sub_cat_id
JOIN hospitals AS h ON h.hospital_id = sc.main_hospital_id
JOIN products AS p ON p.product_id = s.product_id
JOIN product_group AS pg ON pg.id = p.product_group_id
JOIN progress_steps AS ps ON sc.approval_step = ps.step_id
WHERE s.approval_status='2'
AND sc.user_id='$mask5'
问题是 sc 有 3 行而 s 有 6 行。我需要返回所有六行,但目前它只返回 3,每个 from s 对应于 sc。
根据我现在正在尝试的建议:
SELECT * FROM submissions AS s
LEFT JOIN submission_category AS sc ON (s.submission_category = sc.sub_cat_id AND sc.user_id='$mask5' )
JOIN hospitals AS h ON h.hospital_id = sc.main_hospital_id
JOIN products AS p ON p.product_id = s.product_id
JOIN product_group AS pg ON pg.id = p.product_group_id
JOIN progress_steps AS ps ON sc.approval_step = ps.step_id
WHERE s.approval_status='2'
但仍然得到三排,而不是六排?