####判断两个拼接字符串拆分之后是否有相同的子字符串,大于0存在,否则不存在
DROP FUNCTION
IF EXISTS F_judgeChildStr;
CREATE FUNCTION F_judgeChildStr (pstr VARCHAR(600),cstr VARCHAR(600)) RETURNS VARCHAR (100)
BEGIN
declare returnValues VARCHAR (100);
select count(1) into returnValues from (
select
SUBSTRING_INDEX( SUBSTRING_INDEX(pstr , ',', help_topic_id + 1 ), ',',- 1 ) pstr
from
mysql.help_topic
where
help_topic_id < ( length(pstr) - length( replace (pstr, ',', '' ) ) + 1 )
) m1,
(
select
SUBSTRING_INDEX( SUBSTRING_INDEX(cstr , ',', help_topic_id + 1 ), ',',- 1 ) cstr
from
mysql.help_topic
where
help_topic_id < ( length(cstr) - length( replace (cstr, ',', '' ) ) + 1 )
)m2
where
m1.pstr = m2.cstr; RETURN returnValues ;
END;