i可以单独使用ARRAY_CONTAINS
函数ARRAY_CONTAINS(array, value1) AND ARRAY_CONTAINS(array, value2)
获得结果。但是我不想多次使用ARRAY_CONTAINS
。是否有一个函数可以在数组中一次检查两个值。
**从评论中更新**
表包含:ID,标签,数组[类型],数组[feature],textual1,numeric1和numeric2列。
查询是:(
SELECT id, label, textual1
FROM table
WHERE
ARRAY_CONTAINS(type, 'productType1')
AND ARRAY_CONTAINS(feature, 'feature1')
AND ARRAY_CONTAINS(feature, 'feature2') AND numeric1 > 3)
UNION (
SELECT id, label, textual1
FROM table
WHERE
ARRAY_CONTAINS(type, 'productType1')
AND ARRAY_CONTAINS(feature, 'feature1')
AND ARRAY_CONTAINS(feature, 'feature3')
AND numeric2 > 4
)
ORDER BY label
您的查询可以如下写入 -
SELECT id, label, textual1
FROM table
WHERE ARRAY_CONTAINS(type ,'productType1')
AND ARRAY_CONTAINS(feature ,'feature1')
AND (
( ARRAY_CONTAINS(feature ,'feature2')
AND numeric1 > 3
)
or ( ARRAY_CONTAINS(feature ,'feature3')
AND numeric2 > 4
)
)
ORDER BY label