mysql 动态执行SQL文

在mysql存储过程中动态执行sql文

mysql> PREPARE stmt1 FROM 'SELECT SQRT(POW(?,2) + POW(?,2)) AS hypotenuse';
mysql> SET @a = 3;
mysql> SET @b = 4;
mysql> EXECUTE stmt1 USING @a, @b;
mysql> SET @a = 'select * from table1 ';
mysql> SET @b = 'where column1>10 limit 1';
mysql> SET @a = concat(@a,@b);
mysql> PREPARE stmt1 FROM @a;
mysql> EXECUTE stmt1;

参考:
http://dev.mysql.com/doc/refman/5.0/en/sql-syntax-prepared-statements.html








已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页