几天前我问了一个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/