开发者

Merging two rows into one row with MYSQL

开发者 https://www.devze.com 2023-03-25 13:35 出处:网络
IDColumn1Column2Column3 1data1data3 1data2 from table above, may I perform a single query to get this? :
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

精彩评论

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

关注公众号