我正在构建查询,该查询使用我当前的查询created_at列根据月份过滤数据
查询:
SELECT id, title, body, created_at, from posts ORDER BY id DESC
现在,当created_at列打印时,它显示以下结果2020-03-01 07:50:07,但我想打印月份名称,例如三月,四月 应该如何实现
谢谢
最佳答案
查询:
SELECT id, title, body, MONTHNAME(created_at) from posts ORDER BY id DESC
将created_at替换为MONTHNAME(created_at)
MONTHNAME(col_name) 函数将显示月份名称
关于mysql - 按月份过滤数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60530507/