gpt4 book ai didi

php - 检查在 mysql startdate enddate 列之间找到的日期 renge

转载 作者:行者123 更新时间:2023-11-30 22:32:48 25 4
gpt4 key购买 nike

在我的数据库中有两列和如下数据

   StartDate      Enddate
2015-10-01 2015-10-30
2015-10-15 2015-11-15
2015-09-15 2015-10-15

如果我搜索 startdat :​​ 2015-10-16 Enddate : 2015-10-20 而不是想要以上所有结果,请帮助我

我的查询如下

Select * from campaign as c LEFT JOIN campaign_team as t ON c.campaign_id=t.campaign_id where t.user_id
='6' and
(campaign_sdate BETWEEN '2015-10-16' AND '2015-10-20' or campaign_edate BETWEEN '2015-10-16' AND '2015-10-20'
or ( campaign_sdate <= 2015-10-16 and campaign_edate >= 2015-10-20 ) );

提前致谢

最佳答案

你写了相反的条件

or ( campaign_sdate >= 2015-10-16 and campaign_edate <= 2015-10-20 ) );

当你使用它时删除 BETWEEN

最终查询,

Select * from campaign as c LEFT JOIN campaign_team as t ON c.campaign_id=t.campaign_id where t.user_id
='6' or ( campaign_sdate >= 2015-10-16 and campaign_edate <= 2015-10-20 ) );

关于php - 检查在 mysql startdate enddate 列之间找到的日期 renge,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33407462/

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