1

i want to create stored procedure with LIKE operation but getting error and the answers** that i saw was outdated for current version. How can i write the procedure correctly

Getting same error: 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 'LIKE '%' + @Name + '%' AND; brand LIKE '%' + @Brand+ '%' AND; `description' at line 2

Tried these:

BEGIN
 `name` LIKE '%' + @Name + '%' AND
 `brand` LIKE '%' + @Brand+ '%' AND
 `description` LIKE '%' + @Desc + '%' AND
 `type` LIKE '%' + @Type + '%';
END


BEGIN
 `name` LIKE CONCAT('%', @Name, '%') AND
 `brand` LIKE CONCAT('%', @Brand, '%') AND
 `description` LIKE CONCAT('%', @Desc, '%') AND
 `type` LIKE CONCAT('%', @Type, '%');
END

doc: https://dev.mysql.com/doc/refman/5.7/en/create-procedure.html

Screenshot: screen error

2
  • What actually do you want to do? (select, update something, insert to another table...) in your BEGIN-END section you just wrote partial query , looks like the where part and not a full query
    – shushu304
    Jan 3, 2021 at 15:50
  • Besides two direct issues with the code that I flagged as duplicates, I second to @shushu304 : I do not get what you try to accomplish with your code. Pls ask a new question after fixing the two issues if you need further help!
    – Shadow
    Jan 3, 2021 at 15:53

0

Browse other questions tagged or ask your own question.