mysql存儲過程,有輸入輸出的 Sql代碼 DELIMITER //; CREATE PROCEDURE queryTotalNum(OUT totalNum INT , IN tableName varchar(40), IN conditions varchar(300)) begin declare stmt varchar(2000); declare num int; if LENGTH(conditions)>1 then begin set @sqlstr=concat('SELECT COUNT(*) INTO @num from ',tableName,' where ',conditions); end; else begin set @sqlstr=concat('SELECT COUNT(*) INTO @num from ',tableName); end; end if; prepare stmt from @sqlstr; execute stmt; deallocate prepare stmt; set totalNum = @num; end;