gpt4 book ai didi

MySQL 查询多个 where 返回 null

转载 作者:行者123 更新时间:2023-11-29 19:09:15 24 4
gpt4 key购买 nike

我的以下查询对于设置和预算都返回 null。

但是,如果我删除值 11 之后的所有内容,它就会起作用。

有人知道这是怎么回事吗?

SELECT  SUM(setup_fee) AS setup, 
SUM(budget) AS budget
FROM gdn
WHERE client = 11
AND start_date BETWEEN 2017-03-26 AND 2017-04-30
AND end_date BETWEEN 2017-03-26 AND 2017-04-30

最佳答案

您的问题既不是缺少分组依据,也不是条件周围的括号,而是您必须引用这些日期值:

SELECT  SUM(setup_fee) AS setup, 
SUM(budget) AS budget
FROM gdn
WHERE client = 11
AND start_date BETWEEN '2017-03-26' AND '2017-04-30'
AND end_date BETWEEN '2017-03-26' AND '2017-04-30'

您可以看到复制的问题的简化版本 here

关于MySQL 查询多个 where 返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43228115/

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