惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
博客园 - Franky
J
Java Code Geeks
V
Visual Studio Blog
G
Google Developers Blog
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
博客园 - 司徒正美
The GitHub Blog
The GitHub Blog
腾讯CDC
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
博客园 - 【当耐特】
IT之家
IT之家
I
InfoQ
U
Unit 42
C
Check Point Blog
Martin Fowler
Martin Fowler

博客园 - 谁是菜鸟?

mysql数据区分大小写 css hack java 乱码 panic user 44/45 Lock wait timeout exceeded; try restarting transaction window.onbeforeunload(支持firefox,ie,Safari) 配置SFS2.x的调试环境 mysql异常处理 常用linux命令 x86_64-unknown-linux - 谁是菜鸟? - 博客园 memcached资料 js ping - 谁是菜鸟? - 博客园 mysql roll back 为没有自动增长列的表添加自动增长列并更新现有数据 SmartFox Server 控制pubMsg - 谁是菜鸟? mysql 命令 java.util.ConcurrentModificationException RenRen应用接入样例 - 谁是菜鸟? - 博客园 jxl read and write excel
mysql 动态sql
谁是菜鸟? · 2010-06-22 · via 博客园 - 谁是菜鸟?

变量:gid,hostid  

1,基本查询

    SET @tname = concat('scoreinfo',gid);
    SET @sql = concat('SELECT * from ',@tname,' WHERE host_id = ',hostid);
    PREPARE stmt1 FROM @sql;
    EXECUTE stmt1; 

2:查询并赋值(赋值对象必须是session级别的变量)

    SET @tname = concat('scoreinfo',gid);
    SET @sql = concat('SELECT count(score) into @total FROM ',@tname,' WHERE host_id = ',hostid);
    PREPARE stmt1 FROM @sql;
    EXECUTE stmt1;