I currently have:
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'
The problem is that sc has 3 rows and s has 6 rows. I need to return all six rows but currently it is only returning 3, one of each from s that corresponds to sc.
Based on the suggestion I am now trying:
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'
But still getting three rows, not six?
Having columns of
LEFT JOINed table[s] inWHERE“turns”LEFT JOINintoINNER(sc.user_id = ‘$mask5’ always returnsNULLor false in case there is no corresponding row in submission_category ). Movesc.user_id=...into join condition :