0

I have this mySQL query:

SELECT 
CONCAT_WS('=>',column_1,column_2,column_3) 
AS column_union 
FROM table

In which the result is the combination of these 3 columns with => as delimiter.

table

Is it possible to concatenate in the same query the result of the first concatenation with any other columns?

For example:

SELECT CONCAT_WS('#**#',column_4,column_5,column_union) 
AS another_column_union 
FROM table

In which the final result another_column_union should look like this way:

value_column_4#**#value_column_5#**#v1=>va=>v0
UgoL
  • 839
  • 2
  • 13
  • 37

1 Answers1

1

You need to use a view, a subquery, or repeat the expression. It can also be simplified to:

SELECT concat_ws('=>', column_1, column_2, column_3) as column_union,
       concat_ws('#**#', column_4, column_5, 
                 concat_ws('=>', column_1, column_2, column_3)
                ) as another_column_union 
FROM table
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • Hi @Gordon, thank you for your reply. I have forgot to specify some important things in the the topic question. Take a look to the delimiter and the final result that I expect in the final concatenation query. – UgoL May 16 '17 at 11:12