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