0

based on my question above, below is the current query

SELECT sv.loaded_by, sv.supervised_by, ph.extra_photo, ph.status 
FROM wla_loading_sv sv 
LEFT JOIN wla_extraPhoto ph ON sv.bl_id = ph.bl_id 
WHERE sv.bl_id = 4747 AND ph.status = 1

from this joined query table, it will show 2 rows of data. If I change the ph.status = 0, the data would not display.

But what I want is, the data for sv.loaded_by, sv.supervised_by still can display, only ph.extra_photo will not display, or show null.

Can anyone help me with this? which one do I need to change?

  • Put `AND ph.status = 1` in the `ON` condition, not `WHERE`. – Barmar Apr 06 '23 at 01:41
  • You can not simultaneously filter with a where clause of ph.status = 1 and also have rows where ph.status = 0. If you remove the AND ph.status =1, you will get a row for every row in wla_loading, even if there is no corresponding row in wla_extraphoto – gview Apr 06 '23 at 01:44

0 Answers0