文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>在mysql中使用动态SQL

在mysql中使用动态SQL

时间:2007-07-29  来源:h0ng123

mysql> set @sql_text:='select count(*) from test';
Query OK, 0 rows affected (0.00 sec)

mysql> prepare stmt from @sql_text;
Query OK, 0 rows affected (0.04 sec)
Statement prepared

mysql> execute stmt;
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (0.19 sec)

mysql> deallocate prepare stmt;
Query OK, 0 rows affected (0.00 sec)

在存储过程中改变@sql_text的值,则可以实现动态SQL的效果了。
但要注意,能够使用prepare的SQL是有限制的:
The following SQL statements can be used in prepared statements: CREATE TABLE, DELETE, DO, INSERT, REPLACE, SELECT, SET, UPDATE, and most SHOW statements. supported. ANALYZE TABLE, OPTIMIZE TABLE, and REPAIR TABLE are supported as of MySQL 5.0.23. Other statements are not yet supported.
 
来源:http://blog.chinaunix.net/u/25477/showart_258650.html
排行榜 更多 +
仙灵外传vivo手机版本

仙灵外传vivo手机版本

角色扮演 下载
不一样的修仙2折相思

不一样的修仙2折相思

策略塔防 下载
不一样的修仙2免广告

不一样的修仙2免广告

策略塔防 下载