Home >Database >Mysql Tutorial >创建mysql存储过程_MySQL

创建mysql存储过程_MySQL

WBOY
WBOYOriginal
2016-06-01 13:51:301059browse

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 ;

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