Search code examples
mysqlsqlconcatenation

MySQL concatenation operator


I don't know concatenation operator for MySQL.

I have tried this code for concatenation:

SELECT vend_name || ' (' || vend_country || ')'
FROM Vendors
ORDER BY vend_name;

But it didn't work. Which operator should I use to concatenate strings?


Solution

  • You were using ORACLE type of concatenation. MySQL's Should be

     SELECT CONCAT(vend_name, '(', vend_country, ')')
    

    Call the CONCAT() function and separate your values with commas.