GROUP_CONCAT中的DATE_FORMAT

时间:2014-08-28 20:52:27

标签: mysql

我试图执行此查询,但它会在几个月内返回一个空单元格:

SELECT 
 year(publication) AS year, 
 GROUP_CONCAT(DISTINCT DATE_FORMAT(month(publication), '%M') ORDER BY month(publication) ASC) AS months
 from texts 
 GROUP BY year(publication) ORDER BY year (publication) DESC

Whitout DATE_FORMAT,查询工作正常。但我需要返回几个月的名字。

2 个答案:

答案 0 :(得分:3)

替换

DATE_FORMAT(month(publication), '%M') 

DATE_FORMAT(publication, '%M') 

答案 1 :(得分:-1)

您还可以使用GROUP_CONCAT(from_unixtime(timestamp,'%d-%m-%y %H:%i:%s') separator ', ')