MySQL 连接运算符

2021-11-20 00:00:00 sql concatenation mysql

我不知道 MySQL 的连接运算符.

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?

推荐答案

您正在使用 ORACLE 类型的串联.MySQL的应该是

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

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

调用 CONCAT() 函数并用逗号分隔您的值.

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

相关文章