I have two comma seaperated strings, string1 = 'abc,cde,efg' and string2 = 'abc,efg' . Is there any way that I can find any of the substrings in strig1 to match the string2 substring? I have tried to split the string on the basis of a comma and find any string from the left side matches the substring of the right string then true else false.
CodePudding user response:
You can do so like this:
SELECT s1.value
FROM STRING_SPLIT('abc,cde,efg', ',') AS s1
CROSS JOIN STRING_SPLIT('abc,efg', ',') AS s2
WHERE s1.value = s2.value
-- returns ('abc') and ('efg')