MySQL combine two columns into one column
My guess is that you are using MySQL where the +
operator does addition, along with silent conversion of the values to numbers. If a value does not start with a digit, then the converted value is 0
.
So try this:
select concat(column1, column2)
Two ways to add a space:
select concat(column1, ' ', column2)
select concat_ws(' ', column1, column2)
Try this, it works for me
select (column1 || ' '|| column2) from table;
It's work for me
SELECT CONCAT(column1, ' ' ,column2) AS newColumn;
This is the only solution that would work for me, when I required a space in between the columns being merged.
select concat(concat(column1,' '), column2)
If you are Working On Oracle
Then:
SELECT column1 || column2 AS column3
FROM table;
OR
If You Are Working On MySql Then:
SELECT Concat(column1 ,column2) AS column3
FROM table;