更新时间:2024-11-26 GMT+08:00
分享

EXECUTE

语法

EXECUTE statement_name [ USING parameter1 [ , parameter2, ... ] ]

描述

执行预编译的SQL语句(prepared statement),并可以使用USING来指定输入参数。

示例

  • 执行一个不带输入参数的预编译语句
    PREPARE my_select1 FROM SELECT name FROM fruit;
    EXECUTE my_select1;
  • 执行一个带有两个输入参数的SQL语句
    PREPARE my_select2 FROM SELECT name FROM  fruit WHERE name= ? and price< ?;
    EXECUTE my_select2 USING  'peach',10;
    This is equivalent to:
    SELECT name FROM fruit WHERE name = 'peach' AND price<10;

相关文档