(MySql) Join Two Columns to Single Column
Many times one want to join 2 columns in a MySql table. For example, you have saved 'First Name' and 'last name' in separate columns and now want to get 'Full Name' as part of query output.
MySql Join Two Columns as single Column
In MySql, the operator to join two columns is called
concat. You can use `concat to join two columns.
# How to Join two columns select concat(column1, column2) as column3 from table;
If you want to insert a space in between, then you can use following:
select concat(column1, ' ', column2) as column3 from table; or select concat_ws(' ', column1, column2) as column3 from table;
Please note that in other databases, people use
+ (Plus sign) to join two columns, but it does not work in MySql. In Mysql plus sign is only usable for summing up integer columns. If you trying to sum up varchar columns, you will get 0 (zero).