gpt4 book ai didi

mysql - 仅检索当天没有事件的 field

转载 作者:太空宇宙 更新时间:2023-11-03 11:08:54 27 4
gpt4 key购买 nike

我正在尝试从 venues 表中检索当天没有事件的行。

这是我检索事件的方式:

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 之间的所有事件

这是我目前检索 field 的方式:

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

关于mysql - 仅检索当天没有事件的 field ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9977644/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com