0
我需要下面的代碼將所有三個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行
http://en.m.wikipedia.org/wiki/Database_normalization – HerrSerker 2013-05-12 11:13:50