mysql dynamically executes stored procedure statements
- 2020-05-09 19:24:28
- OfStack
Let me write down one for your reference
Note 1 that there are a number of defined functions available in MYSQL, such as the splicing function Concat() above, which can be helpful.
create procedure sp_find(pfind varchar(500)
BEGIN
DECLAR msql varchar(2000);
SET @MyQuery=Concat('select * from table where ',pfind);
PREPARE msql from @MyQuery;
EXECUTE msql;
END
Note 1 that there are a number of defined functions available in MYSQL, such as the splicing function Concat() above, which can be helpful.