MySql将方法替换为"/&引用;在输入字符串中
我有一个存储过程,它像MySql将方法替换为"/&引用;在输入字符串中,mysql,sql,Mysql,Sql,我有一个存储过程,它像 myProcedure("Fashion,Sports", "Shirts, Pants", null, null , "0,100") myProc( productType, Item, ProductID, costprice, minMaxQuantity); 现在,对于第一个参数,myProcedure创建一个类似于 Select * from myTable where ProductType in ('Fashion,'Sports') and Item
myProcedure("Fashion,Sports", "Shirts, Pants", null, null , "0,100")
myProc( productType, Item, ProductID, costprice, minMaxQuantity);
现在,对于第一个参数,myProcedure
创建一个类似于
Select * from myTable where ProductType in ('Fashion,'Sports')
and Item in ('Shirts','Pants');
为了创建“in”语句部分,我使用mysql的“Repalce”方法
SET whrClause = REPLACE(productType, "," ," ',' ");
通过这种方式,我可以进行正确的查询,甚至可以得到所需的结果
但问题是,在输入中,有时我会
myProcedure("Adm/Husleie/Royalty,Fashion,Sports", "Shirts, Pants", null, null , "0,100");
现在讨论第一个参数的第一部分(即Adm/Husleie/Royalty
)
替换方法无法正常工作。我没有得到关于ProductType=Adm/Husleie/Royalty
的结果,但对于时尚和体育,我得到了结果。有人能帮我吗。如何使用绝对字符串以及替换方法。试试以下方法:
将replace语句更改为
SET whrClause =REPLACE(REPLACE(productType, "," ," ',' "),"/" ," ',' ");
实际上在数据库中,我们有带“/”(Adm/Husleie/Royalty)的productType,所以我不能替换它。我尝试在Replace方法中使用Adm\/Husleie\/Royalty,但仍然没有给出任何结果