I want to update my column by joining both column to one.
FirstName | Name |
---|---|
John | Kowalsky |
Adam | Smith |
null | Bush |
I would like to achieve such an effect in column
"Name
John Kowalsky
Adam Smith
Bush
I tried subselect but dont work
I want to update my column by joining both column to one.
FirstName | Name |
---|---|
John | Kowalsky |
Adam | Smith |
null | Bush |
I would like to achieve such an effect in column
"Name
John Kowalsky
Adam Smith
Bush
I tried subselect but dont work
No sub-select required:
update the_table
set name = concat_ws(' ', firstname, name);
But updating the column this way is a bad idea as you lose the real (last) name.
I would put this into a view:
create view the_table_with_full_name
as
select name, firstname, concat_ws(' ', firstname, name) as full_name
from the_table;
concat_ws()
will properly deal with nulls or empty strings