,我不確定如何修改它給我所期望的輸出,下文中詳細說明:輸出是MYSQL - 拼合我有以下查詢的一些問題表查詢
SELECT listup.NodeNumber As Node, listup.Station As Extension,
CASE WHEN VoiceServer = 1 THEN KeyDescription ELSE '' END AS 'Key1',
CASE WHEN VoiceServer = 2 THEN KeyDescription ELSE '' END AS 'Key2',
CASE WHEN VoiceServer = 3 THEN KeyDescription ELSE '' END AS 'Key3',
CASE WHEN VoiceServer = 4 THEN KeyDescription ELSE '' END AS 'Key4',
CASE WHEN VoiceServer = 5 THEN KeyDescription ELSE '' END AS 'Key5',
CASE WHEN VoiceServer = 6 THEN KeyDescription ELSE '' END AS 'Key6',
CASE WHEN VoiceServer = 7 THEN KeyDescription ELSE '' END AS 'Key7',
CASE WHEN VoiceServer = 8 THEN KeyDescription ELSE '' END AS 'Key8',
CASE WHEN VoiceServer = 9 THEN KeyDescription ELSE '' END AS 'Key9',
CASE WHEN VoiceServer = 10 THEN KeyDescription ELSE '' END AS 'Key10'
FROM listup
ORDER BY listup.NodeNumber, listup.Station;
如下:
Node Extension Key1 Key2 Key3 etc.
N100 14311 14311
N100 14311 14308
N100 14311 14309
N100 14311 14314
N100 14311 14412
N100 14311 14535
N100 14311 14316
N100 14311 14456
N100 14312 14312
N100 14312 14442
N100 14312 14311
N100 14312 14314
N100 14312 14456
N100 14312 14309
N100 14312 14308
我想擁有這一切出現在同一行,所以扁平化這樣.. 如。
N100 14311 14311 14308 14309 14314 14412 14535 14316 14456
N100 14312 14312 14442 14311 14314 14456 14309 14308
@Syeda:稱呼和陳詞是毫無價值的;浪費屏幕房地產。 –