我正在尝试从场所表中检索当天没有发生任何事件的行。

这就是我检索事件的方式:

SELECT
    events.*,
    venues.*,
    party_types.PARTYTYPE
FROM events
INNER JOIN venues
    ON events.VENUE_LOCATION = venues.ID
WHERE start_datetime >= '$DATE_START_SELECTED'
AND end_datetime < '$DATE_END_SELECTED'
GROUP BY events.ID


其中$ DATE_START_SELECTED和$ DATE_END_SELECTED是PHP变量,基本上说“接受Date1和Date2之间的所有事件”。

这是我目前检索场地的方式:

SELECT
venues.*
FROM venues
GROUP BY venues.VENUE_NAME


我该如何检索当天没有任何活动的所有场所(取决于PHP变量)?

感谢大家! :)

最佳答案

SELECT
venues.*
FROM venues
LEFT JOIN events ON events.VENUE_LOCATION = venues.ID  AND start_datetime >= '$DATE_START_SELECTED' AND end_datetime < '$DATE_END_SELECTED'
where events.VENUE_LOCATION IS NULL
GROUP BY venues.VENUE_NAME

10-06 06:16