Home >Database >Mysql Tutorial >mysql 动态执行存储过程语句_MySQL

mysql 动态执行存储过程语句_MySQL

WBOY
WBOYOriginal
2016-06-01 13:19:30864browse

bitsCN.com 下面写一个给大家做参考啊

create procedure sp_find(pfind varchar(500)
BEGIN
DECLAR msql varchar(2000);
SET @MyQuery=Concat('select * from 表 where ',pfind);
PREPARE msql from @MyQuery;
EXECUTE msql;
END

注意一点的就是MYSQL中有好多已经定义好的函数可以使用,比如上面的拼接函数Concat(),利用好这些函数会有很多帮助的。

bitsCN.com

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn