Sample Header Ad - 728x90

Redshift: Return rows if value exists in cell array

5 votes
2 answers
5061 views
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.
Asked by Myg0t (51 rep)
Jan 3, 2017, 04:18 PM
Last activity: Jan 25, 2025, 08:08 AM