sql存储过程Quotes()

问题描述 投票:0回答:1

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

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'

请帮助解决此问题。

mysql sql stored-procedures quotes
1个回答
0
投票

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

SELECT CASE
         WHEN sex LIKE quote('%') THEN
           quote('Person')
       END AS sex
       FROM tablename;
© www.soinside.com 2019 - 2024. All rights reserved.