我想做一个 MySQL 存储过程
DELIMITER $$
DROP PROCEDURE IF EXISTS `SECTOR_INDUSTRY_SP` $$
CREATE PROCEDURE `SECTOR_INDUSTRY_SP`(IN RINSERIES TEXT, IN COMMUNITYIDS TEXT)
READS SQL DATA
BEGIN
SELECT *
from PROFESSIONAL_IDENTITY_MERGED p , std_company_detail s
where (p.pim_company_id = s.cid) AND p.pim_community_id IN ('+'+COMMUNITYIDS+'+')
AND p.pim_rin IN ('+'+RINSERIES+'+');
END $$
DELIMITER ;
如您所见,我有两个参数来调用此过程 RINSERIES,它们将是文本格式,例如 '12312,1234,1239'
SELECT *
from PROFESSIONAL_IDENTITY_MERGED p , std_company_detail s
where (p.pim_company_id = s.cid) AND p.pim_community_id IN ('12312,1234,1239')
AND p.pim_rin IN ('2,5,8');
但我希望这个查询看起来像下面
SELECT *
from PROFESSIONAL_IDENTITY_MERGED p , std_company_detail s
where (p.pim_company_id = s.cid) AND p.pim_community_id IN (12312,1234,1239)
AND p.pim_rin IN (2,5,8);
我怎样才能做到这一点?谢谢!