欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

创建mysql存储过程_MySQL

程序员文章站 2022-05-26 09:22:12
...
delimiter //

CREATE PROCEDURE get_trees(in conditions varchar(2048), in fields varchar(2048) , in sort char(255), in start int, in num int)
BEGIN
/* 获得10条记录 */
SET @sql = CONCAT(’SELECT ‘, fields, ‘ FROM Persons WHERE ‘, conditions, ‘ ORDER BY ‘, sort, ‘ LIMIT ‘, start, ‘,’, num);
PREPARE sqlstmt FROM @sql;
EXECUTE sqlstmt;
DEALLOCATE PREPARE sqlstmt;
END//

delimiter ;

相关标签: mysql 存储