http://dev.mysql.com/doc/refman/5.7/en/sql-syntax-prepared-statements.html
1 CREATE TABLE t1 (a INT NOT NULL); 2 INSERT INTO t1 VALUES (4), (8), (11), (32), (80); 3 SET @table = ‘t1‘; 4 SET @s = CONCAT(‘SELECT * FROM ‘, @table); 5 PREPARE stmt3 FROM @s; 6 EXECUTE stmt3;
1 SET @s = ‘SELECT SQRT(POW(?,2) + POW(?,2)) AS hypotenuse‘; 2 PREPARE stmt2 FROM @s; 3 SET @a = 6; 4 SET @b = 8; 5 EXECUTE stmt2 USING @a, @b;
1 PREPARE stmt1 FROM ‘SELECT SQRT(POW(?,2) + POW(?,2)) AS hypotenuse‘; 2 SET @a = 3; 3 SET @b = 4; 4 EXECUTE stmt1 USING @a, @b; 5 SHOW VARIABLES LIKE ‘%a%‘;
时间: 2024-10-08 00:48:20