gpt4 book ai didi

mysql - mysql 不考虑日期范围

转载 作者:行者123 更新时间:2023-11-29 12:16:39 24 4
gpt4 key购买 nike

我的选择查询是这样的,我在这个日期范围内的“processbackup”表中有记录,但它仍然没有考虑结果中的日期范围,我得到零行。

SELECT
DATE_FORMAT(processDate,'%d-%m-%Y') AS processDate,
DATE_FORMAT(rDate,'%d-%m-%Y') AS rDate,
designMaster.dNo,
processbackup.desWet,
reciveWet,
item.itemNm,
processbackup.workerId
FROM processbackup
LEFT JOIN designMaster
ON designMaster.designMasterId = processbackup.designMasterId
LEFT JOIN item AS i
ON i.itemId = designMaster.itemId
LEFT JOIN item
ON item.itemId = designMaster.itemId
WHERE processbackup.workerId = 1
AND (processDate BETWEEN '2015-04-04' AND '2015-04-14')

最佳答案

您的查询没有任何问题。

运行它:

SELECT processDate 
FROM processbackup
LEFT JOIN designMaster
ON designMaster.designMasterId = processbackup.designMasterId
LEFT JOIN item AS i
ON i.itemId = designMaster.itemId
LEFT JOIN item
ON item.itemId = designMaster.itemId
WHERE processbackup.workerId = 1
AND (processDate BETWEEN '2015-04-04' AND '2015-04-14')

查看返回的日期。如果它们不在 2015-04-04 和 2015-04-14 之间,您将不会得到任何结果。

请注意,如果 processDate 是日期时间,您的结果将不包含 2015 年 4 月 14 日的值。您需要在 WHERE 子句中包含时间或将其更改为 2015-04-15。

关于mysql - mysql 不考虑日期范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29700356/

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