the fulltext field contains html tags and some resources and I want to get all 'src' attributes from that. some records maybe have several 'src'.
now, I dont know how I can write a query to obtain the desired result. and this is my code
DROP FUNCTION IF EXISTS SPLIT_STR;
CREATE FUNCTION SPLIT_STR(
x text,
delim VARCHAR(10),
co INT
)
RETURNS VARCHAR(255) DETERMINISTIC
BEGIN
WHILE co >= 0 DO
SET x = RIGHT(x, ( (CHAR_LENGTH(x)) - (InStr(x,'src')) + 1 ));
RETURN SUBSTR(x, 1, 40);
END WHILE;
END
#---------------------------------------------------
SELECT id, SPLIT_STR(test.fulltext, 'src',ROUND (
(
LENGTH(test.fulltext)
- LENGTH( REPLACE ( test.fulltext, "src", "") )
) / LENGTH("src")
))
FROM test
WHERE test.fulltext LIKE '%src%'
and the result should be like this result