根据月份过滤数据
filter data according to months
我正在构建查询,该查询使用 created_at 列根据月份过滤数据,我当前的查询
查询:
SELECT id, title, body, created_at, from posts ORDER BY id DESC
现在当 created_at 列打印时它显示以下结果 2020-03-01 07:50:07 但我想打印月份名称 三月、四月
应该如何实现
谢谢
您似乎在寻找 MySQL date function MONTHNAME()
:
SELECT id, title, body, MONTHNAME(created_at) created_month
FROM posts
ORDER BY id DESC
查询:
SELECT id, title, body, MONTHNAME(created_at) from posts ORDER BY id DESC
将 created_at 替换为 MONTHNAME(created_at)
MONTHNAME(col_name) 函数将显示月份名称
我正在构建查询,该查询使用 created_at 列根据月份过滤数据,我当前的查询
查询:
SELECT id, title, body, created_at, from posts ORDER BY id DESC
现在当 created_at 列打印时它显示以下结果 2020-03-01 07:50:07 但我想打印月份名称 三月、四月 应该如何实现
谢谢
您似乎在寻找 MySQL date function MONTHNAME()
:
SELECT id, title, body, MONTHNAME(created_at) created_month
FROM posts
ORDER BY id DESC
查询:
SELECT id, title, body, MONTHNAME(created_at) from posts ORDER BY id DESC
将 created_at 替换为 MONTHNAME(created_at)
MONTHNAME(col_name) 函数将显示月份名称