This is a discussion on how to append the % to a IN parameter for stored procedure within the MySQL forums, part of the Database Server Software category; --> Hi, i keep getting syntax error I am doing this CREATE PROCEDURE `db_test`.`sp_GetShopsByKeyword`(IN keyword varchar(100)) /*LANGUAGE SQL | [NOT] ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, i keep getting syntax error I am doing this CREATE PROCEDURE `db_test`.`sp_GetShopsByKeyword`(IN keyword varchar(100)) /*LANGUAGE SQL | [NOT] DETERMINISTIC | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA } | SQL SECURITY { DEFINER | INVOKER } | COMMENT 'string'*/ BEGIN SELECT * FROM shops where title like '%' + keyword '%'; END$$ this stored procedure is meant for search purposes. i am taking in a user input from the text box and then running the stored procedure where i can return all results whose title contain the keyword. How do i achieve that result ? I tried googling a bit but to no avail. Please advise. Thank you. |
| |||
| Kei Simone wrote: > Hi, > > i keep getting syntax error > > I am doing this > > CREATE PROCEDURE `db_test`.`sp_GetShopsByKeyword`(IN keyword > varchar(100)) > /*LANGUAGE SQL > | [NOT] DETERMINISTIC > | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA } > | SQL SECURITY { DEFINER | INVOKER } > | COMMENT 'string'*/ > > BEGIN > > > > SELECT * FROM shops where title like '%' + keyword '%'; > > END$$ > > > this stored procedure is meant for search purposes. > > i am taking in a user input from the text box and then running the > stored procedure where i can return all results whose title contain > the keyword. > > How do i achieve that result ? I tried googling a bit but to no avail. > > Please advise. > > Thank you. try something syntactically correct. SQL isn't PERL, BASIC or PHP. try: like concat('%',keyword,'%'); or if you prefer an ANSI Standard solution: like '%'||keyword||'%'; |
| ||||
| On Mar 12, 10:47 am, Michael Austin <maus...@firstdbasource.com> wrote: > Kei Simone wrote: > > Hi, > > > i keep getting syntax error > > > I am doing this > > > CREATE PROCEDURE `db_test`.`sp_GetShopsByKeyword`(IN keyword > > varchar(100)) > > /*LANGUAGE SQL > > | [NOT] DETERMINISTIC > > | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA } > > | SQL SECURITY { DEFINER | INVOKER } > > | COMMENT 'string'*/ > > > BEGIN > > > SELECT * FROM shops where title like '%' + keyword '%'; > > > END$$ > > > this stored procedure is meant for search purposes. > > > i am taking in a user input from the text box and then running the > > stored procedure where i can return all results whose title contain > > the keyword. > > > How do i achieve that result ? I tried googling a bit but to no avail. > > > Please advise. > > > Thank you. > > try something syntactically correct. > > SQL isn't PERL, BASIC or PHP. > > try: > like concat('%',keyword,'%'); > or if you prefer an ANSI Standard solution: > like '%'||keyword||'%'; Thank you. That was fantastic. Is there any books or online resources you can recommend me? Is there any advice you can give me? I am developing a asp.net 2.0 web application running on MySQL 5.0. there may be some extensive searching functions involved, but my knowledge of MySQL is limited to writing standard stored procedures and queries. I know nothing about optimization of search queries or caching. Should I upgrade MySQL 5.0 to 6.0? Thank you. |
| Thread Tools | |
| Display Modes | |
|
|