开发者

Merging two rows into one row with MYSQL

ID        Column1        Column2        Column3
1         data1                         data3
1                        data2

from table above, may I perform a single query to get this? :

ID        Column1        Col开发者_如何学Cumn2        Column3
1         data1          data2          data3


SELECT
  MAX(Column1) AS Column1,
  MAX(Column2) AS Column2,
  MAX(Column3) AS Column3
FROM
  table
GROUP BY
  ID


SELECT
  GROUP_CONCAT(Column1) AS Column1,
  GROUP_CONCAT(Column2) AS Column2,
  GROUP_CONCAT(Column3) AS Column3
FROM table
GROUP BY ID
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜