I am using MySQL and MySQL Workbench 5.2 CE. When I try to concatenate 2 columns, last_name
and first_name
, it doesn't work :
select first_name + last_name as "Name" from test.student
MySQL is different from most DBMSs use of +
or ||
for concatenation. It uses the CONCAT
function:
SELECT CONCAT(first_name, " ", last_name) AS Name FROM test.student
As @eggyal pointed out in comments, you can enable string concatenation with the ||
operator in MySQL by setting the PIPES_AS_CONCAT
SQL mode.