gpt4 book ai didi

php - mysql group_concat 显示所有日期

转载 作者:行者123 更新时间:2023-11-30 22:52:37 27 4
gpt4 key购买 nike

我有 2 个表:

配置文件 userid, fname,lname

时间表:用户 ID、日期、开始时间、结束时间

这是我的查询。

select *, group_CONCAT(distinct(date),'_',start_time,'_',end_time) as dateformat FROM profile, schedule WHERE profile.userid = schedule.pid

这将返回表中的所有日期。但我想做的是只返回某些日子,例如:

date >= DATE(NOW()) and date <= date(now() + 2 day)

所以今天明天和后天。

无论我尝试什么,它只会返回日程表数据库中的所有日期。我需要这个来返回 2 行 userid 5 在配置文件中有 1 行但在计划中有 5 行并且 userid 6 在配置文件中有 1 行在计划中有 2 行查询工作正常它只返回所有日期而不是

"date >= DATE(NOW()) and date <= date(now() + 2 day)"

最佳答案

你尝试过 GROUP BY 吗?

比如 WHERE profile.userid = schedule.pid GROUP BY date

关于php - mysql group_concat 显示所有日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27698571/

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