yangyi
项目合作联系我: yangyi_love@hotmail.com

导航

 

变量: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;

 

posted on 2010-06-22 11:01  谁是菜鸟?  阅读(235)  评论(0编辑  收藏  举报