如何在 mysql 中将 DATETIME 转换为 DATE?

2021-11-20 00:00:00 datetime date mysql

我的查询是这样的.我有一堆条目,我想按日期对它们进行分组.但是我的数据库中没有日期,而是有一个日期时间字段.我该怎么办?

My query is this. I have a bunch of entries and i want to group them by date. But instead of having date in my database, I have a datetime field. What do I do?

select * from follow_queue group by follow_date cast follow_date as date

这行不通.

推荐答案

使用 DATE() 函数:

Use DATE() function:

select * from follow_queue group by DATE(follow_date)

相关文章