create procedure test( in tbl varchar(32),out cnt int(11) )
begin
/*
这里怎么写执行类似
select count(*) into cnt from {$tbl};
的语句
*/
end

解决方案 »

  1.   

    参考:create procedure countNum
    (
    in tbName varchar(100),
    out allPages int
    )
    begin
    set @sqlStr = CONCAT('select count(*) into @allPages from ',tbName);
    prepare sqlstmt from @sqlStr;
    execute sqlstmt;set allPages = @allPages;deallocate prepare sqlstmt;
    end;
      

  2.   

    http://blog.chinaunix.net/u/29134/showart_255219.html