1
如果我找回場館與他們的關閉時間從另一個表像這樣的列表:即使連接表爲空也顯示行嗎?
$fullDate = date('Y-m-d H:i:s');
$query="SELECT
venues.ID,
venues.VENUE_NAME,
locations.LOCATION,
hrs.opening_day,
hrs.opening_time,
hrs.closing_time
FROM venues
INNER JOIN venue_types
ON venues.VENUE_TYPE = venue_types.ID
INNER JOIN locations
ON venues.VENUE_LOCATION = locations.ID
INNER JOIN hours_of_operation hrs
on hrs.venue_id = venues.id
and ((hrs.opening_day=date_format('$fullDate' - INTERVAL (closing_time<opening_time and time('$fullDate')<closing_time) DAY, '%a')))
GROUP BY venues.VENUE_NAME";
我得到的,我已經指定了打開/關閉時間某一天在hours_of_operation
場館的結果。無論當天hours_of_operation
行是否爲空,該如何顯示所有場所?
謝謝! :)
您在此查詢沒有聚集功能,使GROUP BY是不合適的。我懷疑你的意思是使用SELECT DISTINCT ... – Strawberry