how to concatenate n columns into one?

前端 未结 3 1438
余生分开走
余生分开走 2021-01-25 11:00

my goal is if I have this:

colmuns      c1 | c2 | c3 | c4 | c5 | n..
row1          a |  a |  a |  a |  a | 
row2          b |  b |  b |  b |  b |
rowN...
         


        
3条回答
  •  面向向阳花
    2021-01-25 12:00

    If the columns are all known:

    SELECT c1 + c2 + c3 + c4 + c5 AS cAll
    

    However, this won't work if you don't know up front what the columns all are.

    In other words, if you want a query for this specific table it will work, but if you want a general query that will work with different tables (different column names, etc) you'd need to modify the query for each table you want to parse.

提交回复
热议问题