I have a stored procedure which takes input like
myProcedure("Fashion,Sports", "Shirts, Pants", null, null , "0,100")
myProc( productType, Item, ProductID, costprice, minMaxQuantity);
Now for the first parameter, myProcedure creates a mysql query somthing like
Select * from myTable where ProductType in ('Fashion,'Sports')
and Item in ('Shirts','Pants');
For creating “in” statement part I am using “Repalce” method of mysql
SET whrClause = REPLACE(productType, "," ," ',' ");
This way I am able to make a correct query, and even I am getting the desired results.
But the problem is, in input sometime I am getting
myProcedure("Adm/Husleie/Royalty,Fashion,Sports", "Shirts, Pants", null, null , "0,100");
now for first part of the first argument (i.e Adm/Husleie/Royalty)
Replace method is not working properly. I am not getting result for ProductType = Adm/Husleie/Royalty , but for Fashion and Sports I am getting the results. Can someone help me. How can I use absolute string and I can use replace method as well.
try this:
Change your replace statement to