I have table as below
create table myTable (id int,
col1 varchar(20),
col2 varchar(20),
col3 varchar(20),
col4 varchar(20),
col5 varchar(20),
col6 varchar(20),
col7 varchar(20),
col8 varchar(20),
col9 varchar(20)
);
And have data as
insert into myTable values
(1, 'col1','col2','col3','col4','col5','col6','col7','col8','col9');
What I want is output as
id + AllInOne
++++++++++++++++++++++++++++++++++++++++++++++++++
1 + col1-col2-col3-col4-col5-col6-col7-col8-col9
++++++++++++++++++++++++++++++++++++++++++++++++++
Any idea how to get this done with smallest query? I know I could do above with use of CONCATENATE. But I would need is some other way. Maybe some pre-defined MySQL function?
Use CONCAT_WS, that concatenates strings (skipping null ones) with a separator: