QUERY - 多个列中的一个字符串
QUERY - One string in several columns
虽然有 no IN in google sheets unlike in SQL,但我并不是在一列中查找多个字符串。我在多列中寻找一个字符串。
那么
的捷径是什么
=QUERY($A:$K, "select A where B contains '"&N1&"' or C contains '"&N1&"' or D contains'"&N1&"' or E contains '"&N1&"' or F contains '"&N1&"' or G contains '"&N1&"' or H contains '"&N1&"' or I contains '"&N1&"' or J contains '"&N1&"' or K contains '"&N1&"'",3)
?
我希望有类似的东西
=QUERY($A:$K, "select A where B,C,D,E,F,G,H,I,J,K contains '"&N1&"'",3)
好的,您可以尝试两种方法
一个数组公式,计算每行中的匹配项数
=query({A:A,arrayformula(mmult(n(isnumber(find(N1,B:K))),transpose(column(B:K))^0))},"select Col1 where Col2>0")
或一种 hacky 方式,就像在您的问题中加入参考的变通方法
=query(A:K,"select A where B contains '"&N1&"'" & arrayformula(concatenate(" or "&char(column(C:K)+64)& " contains '"&N1&"'")))
(仅适用于单字母列引用,但可能比第一个更快)。
虽然有 no IN in google sheets unlike in SQL,但我并不是在一列中查找多个字符串。我在多列中寻找一个字符串。
那么
的捷径是什么=QUERY($A:$K, "select A where B contains '"&N1&"' or C contains '"&N1&"' or D contains'"&N1&"' or E contains '"&N1&"' or F contains '"&N1&"' or G contains '"&N1&"' or H contains '"&N1&"' or I contains '"&N1&"' or J contains '"&N1&"' or K contains '"&N1&"'",3)
?
我希望有类似的东西
=QUERY($A:$K, "select A where B,C,D,E,F,G,H,I,J,K contains '"&N1&"'",3)
好的,您可以尝试两种方法
一个数组公式,计算每行中的匹配项数
=query({A:A,arrayformula(mmult(n(isnumber(find(N1,B:K))),transpose(column(B:K))^0))},"select Col1 where Col2>0")
或一种 hacky 方式,就像在您的问题中加入参考的变通方法
=query(A:K,"select A where B contains '"&N1&"'" & arrayformula(concatenate(" or "&char(column(C:K)+64)& " contains '"&N1&"'")))
(仅适用于单字母列引用,但可能比第一个更快)。