繁体   English   中英

sql 存储过程引用()

[英]sql Stored Procedures Quotes()

我需要在存储过程中生成这样的字符串。

select case when Sex like '%' then 'Person' end as Sex from tableName;

在存储过程中,我生成了这样的。

select case when Sex like quote(%) then quote(Person) end as Sex from tableName;

我得到的错误是

    Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '%) then quote(Person) end as Sex from tableName' at line 1   0.000 sec

我的 MariaDB 版本是“10.3.16-MariaDB”

请帮助解决此问题。

您没有在第二个查询中引用文字。 尝试:

SELECT CASE
         WHEN sex LIKE quote('%') THEN
           quote('Person')
       END AS sex
       FROM tablename;

但是quote()文字没有太大意义,因为您已经必须转义它们中的任何特殊字符。 所以应用quote()是多余的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM