MySQL:CONCAT_WS 函数在本地运行但不在服务器上运行

标签 mysql concat-ws

几天前我问了一个question关于我的问题,我被建议使用 CONCAT_WS功能。我在本地 mysql 数据库上使用 CONCAT_WS,它运行良好。但它无法在服务器(应用程序托管)上运行并生成以下错误。

FUNCTION test.CONCAT_WS does not exist

错误字符串中的test是我在服务器上的数据库名称。

我的查询是这样的:

SELECT * FROM patient WHERE CONCAT_WS (',', LastName,FirstName,BirthDate ) NOT IN ('Abdul,Quddus,2000-09-30','Wasim,Akram,1993-09-12');

有人可以告诉我问题或建议我在上面的链接问题中提出的另一个解决方案吗?

谢谢

最佳答案

修复它的最简单方法是删除函数名称和括号之间的空格,即 CONCAT_WS(...) 而不是 CONCAT_WS (...).

来自MySQL Manual :

By default, there must be no whitespace between a function name and the parenthesis following it. This helps the MySQL parser distinguish between function calls and references to tables or columns that happen to have the same name as a function.

...

You can tell the MySQL server to accept spaces after function names by starting it with the --sql-mode=IGNORE_SPACE option.

此外,此行为取决于 MySQL 版本,这就是它在一台服务器上工作而在另一台服务器上不起作用的原因,引用“Function Name Parsing and Resolution”手册页:

The number of function names affected by IGNORE_SPACE was reduced significantly in MySQL 5.1.13, from about 200 to about 30.

关于MySQL:CONCAT_WS 函数在本地运行但不在服务器上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3786378/

相关文章:

Mysql Select 查询带限制

php - 如何使用 CONCAT_WS 而不是全文搜索

MySQL 特殊字符 concat_ws

php - CakePHP 3新实体保存失败,没有错误

Mysql串联

mysql - 错误 1143 (42000) : SELECT command denied

php - Zend 和 Doctrine 的日期格式

mysql - 连接mySQL中两个连接的结果

mysql - 如何将另一个表中的 2 列连接到 1 个表?