gpt4 book ai didi

php - mysql 查找日期之间的记录

转载 作者:行者123 更新时间:2023-11-29 23:38:23 25 4
gpt4 key购买 nike

SELECT 
amount,
rh.honoraria_key,
rh.honoraria_name
FROM
xref_speaker_honoraria sh
INNER JOIN xref_contract_speaker xcs ON (
sh.contract_id = xcs.contract_id)
INNER JOIN xref_contract_bureau xcb ON (
xcs.contract_id = xcb.contract_id)
INNER JOIN ref_contract c ON ( xcs.contract_id = c.contract_id )
INNER JOIN ref_honoraria rh ON (
sh.honoraria_id = rh.honoraria_id AND
rh.display_ext>0)
WHERE
sh.speaker_id = 888 AND
xcb.brand_id = 27
AND CAST( c.`start` AS DATE ) < '2014-13-02'
AND CAST( c.`end` AS DATE ) > '2014-13-02'
GROUP BY
rh.honoraria_key
ORDER BY
rh.display_ext

我有上述查询,由于日期问题,它没有返回结果。如果我删除 AND CAST( c.endAS DATE ) > '2014-13-02' 它可以工作,但我想获得两个日期之间的结果。 c.start和c.end的DATA类型是DATETYPE。

有任何提示可以解决这个问题吗?

最佳答案

我不确定为什么要将 DATE 类型转换为 DATE 类型,因此我已在此处将其删除。您可以使用 BETWEEN 运算符检查您提供的日期是否在 startend

之间
WHERE 
sh.speaker_id = 888 AND
xcb.brand_id = 27
'2014-13-02' BETWEEN `c`.`start` AND `c`.`end`

关于php - mysql 查找日期之间的记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26301684/

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