You can translate the question and the replies:

Check if Value in Array

Hi, I have to check if a string is a substring of a longer one. Trivially this would lead to INSTR which doesn't work in this particular case as some of the strings to look for are substrings of others (eg. 'abc', 'abcde', ...). The long string is delimited, so I tried the SPLIT() function. That returns an array. Is there a way to check if a specific string is in the array? Something like the following would be great. ``` WHERE 'abc' IN (SELECT SPLIT(',', 'abcdef,def,ghi')) --should evaluate to False ``` Thanks in advance
user
09-05-2022 06:21:46 -0400
code

1 Answer

Hi, I would be able to find if a string is a substring of a string in the array by using the [POSITION()](https://community.denodo.com/docs/html/browse/8.0/en/vdp/vql/functions/text_functions/text_functions#position) function as below: > with test as > ( > select 'abcdef' as field1 union all > select 'def' as field1 union all > select 'ghi' as field1 > ) > select field1, position('abc' in array_to_string(',',nest(field1))) from test group by field1 Hope this helps!
Denodo Team
10-05-2022 08:27:46 -0400
code
You must sign in to add an answer. If you do not have an account, you can register here