ID Column1 Column2 Column3
1 data1 data3
1 data2
从上表中,我可以执行单个查询来获取此信息吗? :
ID Column1 Column2 Column3
1 data1 data2 data3
答案 0 :(得分:2)
SELECT
MAX(Column1) AS Column1,
MAX(Column2) AS Column2,
MAX(Column3) AS Column3
FROM
table
GROUP BY
ID
答案 1 :(得分:1)
SELECT
GROUP_CONCAT(Column1) AS Column1,
GROUP_CONCAT(Column2) AS Column2,
GROUP_CONCAT(Column3) AS Column3
FROM table
GROUP BY ID