How do I return the rows that include a particular value in a column's cell array?
Imagine we have a table like so:
id name phone values
1 Taylor xxx.xxx.xxxx [4,6,5]
2 John yyy.yyy.yyyy [1,5,2]
3 Peter zzz.zzz.zzzz [6,2,6]
I need to create an SQL query that will return the rows where the value '6' exists in the values array. So the expected output would be:
id name phone values
1 Taylor xxx.xxx.xxxx [4,6,5]
3 Peter zzz.zzz.zzzz [6,2,6]
We are working in Redshift. So, if it is easier, the possibility of using the json_extract_array_element_text('json_string', pos) function could be used. Please note that the length of the values arrays could be different from each other.