DELIMITER // CREATE PROCEDURE in_param(IN motherfuckerA VARCHAR(31),IN motherfuckerB VARCHAR(31)) BEGIN SELECT a.bid,SUM(a.signingNumber),SUM(a.testNumber) FROM ( SELECT ce.bid,COUNT(ce.cid) signingNumber,NULL testNumber FROM ( SELECT b.id bid,cus.id cid,cus.creat_time,cus.large_area_code FROM ( SELECT c.id,c.creat_time,c.large_area_code,c.accendant_id FROM customer c WHERE c.`status` = 'SUCCESS' AND c.account_type = 'SIGNING' ) cus RIGHT JOIN sys_emplyee b ON cus.accendant_id = b.id WHERE cus.large_area_code IN (motherfuckerA) ) ce GROUP BY ce.bid UNION ALL SELECT ce.bid,NULL signingNumber, COUNT(ce.cid) testNumber FROM ( SELECT b.id bid,cus.id cid,cus.creat_time,cus.large_area_code FROM ( SELECT c.id,c.creat_time,c.large_area_code,c.accendant_id FROM customer c WHERE c.`status` = 'SUCCESS' AND c.account_type = 'TEST' ) cus RIGHT JOIN sys_emplyee b ON cus.accendant_id = b.id WHERE cus.large_area_code IN (motherfuckerB) ) ce GROUP BY ce.bid ) a GROUP BY a.bid; END; // DELIMITER ; SET @motherfuckerA='southwestRegion'; SET @motherfuckerB='southRegion'; CALL in_param(@motherfuckerA,@motherfuckerB)