Google 工作表 - 查询单元格值包含以逗号分隔的单元格中的值

Google sheets - query cell value contains value in comma separated cell

我正在尝试查询一组 say fruits,因此我将它们分组到一个逗号分隔的单元格中,我想查询该单元格,但没有得到任何结果。当我在那个单元格中只有一个值说 Apple 它想要一个结果时。我认为使用 contains 可以让我在查询中做到这一点?如果不是,他们是更好的方法吗?

Table

A B
Bob Apple
May Orange
Simon Apple
Sam Pear
Tom Grape

查询

=IFERROR(QUERY('Sheet1'!$A2:$AB500, "select A,C,Y where D contains 'Staff' and (K='Y' or L='Y') and C contains '"&G7&"' ", 0),"None")

G7 包含 'Apple,Pear,Grape,Orange'

尝试更改此部分

C contains '"&G7&"'

C matches '"&SUBSTITUTE(G7, ",", "|")&"'

看看是否有帮助?

编辑:如果您在范围内和 G7 中有括号,请尝试

 =ArrayFormula(IFERROR(QUERY({A:C, regexreplace(B:B, "\(|\)",)}, "select Col1 where Col3 contains 'Team' and Col4 matches '"&SUBSTITUTE(REGEXREPLACE(D2, "\(|\)",), ",", "|")&"' ", 0),"None")) 

看看是否可行?