开发者

stored procedure using like (MySQL)

开发者 https://www.devze.com 2023-04-07 03:08 出处:网络
How can I use the LIKE statement in stored procedures (MySQL) ? I tried both but I still get errors: ..WHERE Des_Articolo LIKE \'%nome_art%\';

How can I use the LIKE statement in stored procedures (MySQL) ?

I tried both but I still get errors:

..WHERE Des_Articolo LIKE '%nome_art%';

..WHERE Des_Articolo LIKE'%',nome_art,'%';

nome_art is declared as

CREATE PROCEDURE  ric_art (IN nome_开发者_高级运维art VARCHAR(100) , OUT msg VARCHAR(100))

Many thanks Roberto


Use CONCAT to concatenate strings:

WHERE Des_Articolo LIKE CONCAT('%', nome_art, '%');

Note: This type of query is slow. If performance is an issue, you may want to consider an alternative approach such as full-text searching.


you can use:

..Where Des_Articolo like CONCAT('%',nome_art,'%');

Bun Leap_kh

0

精彩评论

暂无评论...
验证码 换一张
取 消