Posted By: Anonymous
I’m trying to find a way to combine two columns into one, but keep getting the value ‘0’ in the column instead to the combination of the words.
These are what I’ve tried as well as others:
SELECT column1 + column2 AS column3 FROM table; SELECT column1 || column2 AS column3 FROM table; SELECT column1 + ' ' + column2 AS column3 FROM table;
Could someone please let me know what I’m doing wrong?
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
So try this:
select concat(column1, column2)
Two ways to add a space:
select concat(column1, ' ', column2) select concat_ws(' ', column1, column2)