我有这个数据类型的值
array<struct<id:string,name:string,values:array<string>>
[{id=gid://test/1234,name=尺寸,values=[L、M、S、XS]},{id=gid://test/12345,name=颜色,values=[黑色]} ]
如何查询以获取像这样的输出的大小值 [L、M、S、XS]
我试过这个
SELECT
*
FROM
mytable
CROSS JOIN UNNEST(options) AS t (option_struct)
CROSS JOIN UNNEST(option_struct.values) AS size_value
WHERE
option_struct.name = 'Size'
如果目标是获取数组,则不需要使用第二个
unnest
:
SELECT option_struct.values as size_value
FROM
mytable
, UNNEST(options) AS t (option_struct)
WHERE
option_struct.name = 'Size'