Navicat mysql uses parameters as table names to query stored procedures

First of all to create a new stored procedure mode select in

Set the character length in the created parameter.
Reference reference
c is the parameter that I set here.

IN `c` varchar(100)
BEGIN	
SET @sqlStr:=CONCAT("select * from ",c);
    PREPARE stmt from @sqlStr;
    EXECUTE stmt;
    DEALLOCATE PREPARE stmt; 
END

When calling, you need to pay attention to the number table name can be directly entered, the text needs to be quoted or an error will be reported
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_40938312/article/details/107003062