(“a”,“b”,“c”,“d”),(“c”,“d”) true
(“a”,“b”,“c”,“d”),(“c”,“e”) false
1 BEGIN 2 DECLARE idx INT DEFAULT 0 ; 3 DECLARE len INT DEFAULT 0; 4 DECLARE llen INT DEFAULT 0; 5 DECLARE clen INT DEFAULT 0; 6 DECLARE tmpStr varchar(255); 7 DECLARE curt varchar(255); 8 SET len = LENGTH(setB); 9 WHILE idx < len DO 10 SET idx = idx + 1; 11 SET tmpStr = SUBSTRING_INDEX(setB,",",idx); 12 SET clen = LENGTH(tmpStr); 13 IF idx = 1 THEN SET curt = tmpStr; 14 ELSE SET curt = SUBSTRING(setB,llen+2,clen-llen-1); 15 END IF; 16 IF FIND_IN_SET(curt,setA) > 0 THEN RETURN 1; 17 END IF; 18 IF clen <= llen THEN RETURN 0; 19 END IF; 20 21 SET llen = clen; 22 END WHILE; 23 24 RETURN 0; 25 END