0
有兩個表我正在使用。MYSQL - 顯示所有行,包括空值
ft_form_1
ID | facility_id |承認|放電|人口普查|正在等待| reporting_date | last_modified_date
ft_field_options
ID | option_value | option_name | option_order | list_id
通過以下查詢,我可以從list獲得list_id等於1的所有設施的所有'提交'列表。如果發送重複提交,則只顯示最近的提交。
問題:此查詢只顯示今天提交的設施列表及其隨後發送的數據。我該如何顯示今天還沒有提交的設施清單,並顯示空白或空值?
SELECT t1.facility_id, t2.option_name, t2.option_order, t1.admits,
t1.reporting_date, t1.last_modified_date, t1.discharges, t1.census,
t1.pending, DATE_FORMAT(t1.reporting_date,'%m/%d/%Y') AS nicedate
FROM ft_form_1 t1
LEFT JOIN ft_field_options t2
ON (t1.facility_id = t2.option_value AND t2.list_id = 1)
WHERE (DATE_FORMAT(t1.reporting_date,'%m/%d/%Y') =
DATE_FORMAT(NOW(),'%m/%d/%Y')) AND (t1.last_modified_date=(
SELECT MAX(last_modified_date)
FROM ft_form_1
WHERE facility_id = t1.facility_id))
ORDER BY option_order ASC