Will return 0 or false:
SELECT "5,18,5,7,9,2" REGEXP "[[:<:]](8)[[:>:]]"
Will return 1 or true:
SELECT "5,18,5,7,9,2" REGEXP "[[:<:]](5)[[:>:]]"
For Redshift you must use ~
instead REGEXP on above statements:
SELECT "5,18,5,7,9,2" ~ "[[:<:]](5)[[:>:]]"
MySQL have a a function called find_in_set():
SELECT FIND_IN_SET("c", "a,b,c,d,e");
Any options in redshift to compare string with values in comma separated between two columns.
like col1 = '1,2,3' and col2 '1,2,4,5' for this case the output should give 1 since 1,2 are present in col2
select 1 from tab where col1 like col2