如何将几行合并为一行?

时间:2015-03-26 07:59:22

标签: mysql database view

我怎样才能获得

column1  column2   column3
value1   value2    value3

来自

column1  column2   column3
value1   null      null
null     value2    null
null     null      value3

1 个答案:

答案 0 :(得分:0)

你应该用这个:

SELECT T1.column1, T2.column2, T3.column3 FROM test1 T1
LEFT JOIN test1 T2 ON T2.column2 is not null
LEFT JOIN test1 T3 ON T3.column3 is not null
WHERE T1.column1 is not null