如何在mySQL中创建QUOTENAME函数
我想在mySQL中创建一个QUOTENAME()函数,就像M$SQL Server中的函数一样 这就是它所做的:如何在mySQL中创建QUOTENAME函数,mysql,function,Mysql,Function,我想在mySQL中创建一个QUOTENAME()函数,就像M$SQL Server中的函数一样 这就是它所做的: QUOTENAME returns a Unicode string with the delimiters added to make the input string a valid identifier. The QUOTENAME function uses this syntax: QUOTENAME ( 'string' [ , 'delimiter' ] ) Yo
QUOTENAME returns a Unicode string with the delimiters added to make the input string a valid identifier. The QUOTENAME function uses this syntax:
QUOTENAME ( 'string' [ , 'delimiter' ] )
You pass QUOTENAME a string to be delimited and a one-character string to use as the delimiter. The delimiter can be a square bracket or a single or double quotation mark.
这可能吗?你可以从这样的事情开始——根据eggyal的评论进行构建
DROP FUNCTION IF EXISTS QUOTENAME;
CREATE FUNCTION QUOTENAME (s varchar(50), d CHAR(1))
RETURNS VARCHAR(52)
RETURN CONCAT (d, REPLACE(s, d, CONCAT(d,d)), d);
然后添加您的特殊情况和附加功能。+1问得好。如果您只想引用一个值,那么总会有,但对于标识符,我到目前为止使用的
CONCAT('`',REPLACE(str,'`','`'),'`')
,我从来都不觉得非常满意…而且保留字和带有特殊字符的标识符必须用'`'引用。