我想过滤 bigquery 中的一列,其中
LIKE
应匹配多个模式。比如:
SELECT description
FROM mytable
WHERE
mycol LIKE "%window%"
OR mycol LIKE "%door%"
OR mycol LIKE "%carpet%"
但我希望是这样
SELECT description
FROM mytable
WHERE
mycol LIKE IN ["%window%", "%door%", "%carpet%"]
理想情况下,模式
("window", "door", "carpet",...)
存储在另一个表中(因此它们是动态生成的)。
最好的方法是什么?
您是否正在寻找Quantified Like Operator。
请参阅此处的示例,使用
LIKE ANY
:
WITH Words AS
(SELECT 'Intend with clarity.' as value UNION ALL
SELECT 'Secure with intention.' UNION ALL
SELECT 'Clarity and security.')
SELECT * FROM Words WHERE value LIKE ANY ('Intend%', '%intention%');
/*------------------------+
| value |
+------------------------+
| Intend with clarity. |
| Secure with intention. |
+------------------------*/