我需要以下代码将所有三个proj1
,proj4
和proj5
列根据日期放在一行中。
如您所见,日期相似,但显示在不同的记录中。
MYSQL查询如下:
select DISTINCT dates,proj1,proj4, proj5 from
(SELECT DISTINCT tc.dates AS dates , IF( tc.project_id = 1, tc.minutes, '' ) AS 'proj1',
IF(tc.project_id = 5, tc.minutes, '') AS 'proj5', IF(tc.project_id = 4, tc.minutes, '') AS 'proj4'
FROM timecard AS tc where (tc.dates between '2013-04-01' AND '2013-04-05') ) as X
我需要所有三个proj1
,proj4
并且proj5
记录都显示在同一行中,然后查询应该只有 5 行