【问题标题】:Google Sheet query where literal string contains field value文字字符串包含字段值的 Google 表格查询
【发布时间】:2022-11-30 07:06:58
【问题描述】:

假设您在 Google 表格中有一个属性表......

Col A (Name)
Property 1
Property 2
Property 3
Property 4
Property 5

...并且您想要一个公式驱动的解决方案来提取某些属性的数据,这些属性由逗号分隔的文字字符串指定,例如“Property 2,Property 5”。

我想到了 query() 函数,它使用 mySQL 语法。我尝试了这些 WHERE 查询:

  • SELECT A WHERE 'Property 2, Property 5' LIKE '%{$A}%' -- 没有错误但返回空集。
  • SELECT A WHERE INSTR('Property 2, Property 5', A) -- 返回错误:无法解析函数 QUERY 参数 2 的查询字符串:PARSE_ERROR:在第 1 行第 16 列遇到“'INSTR'”。是期待其中之一:“(”...“(”...

是否有其他一些查询在大海捞针中查找针头,其中大海捞针是文字字符串,而针头是查询中的一个字段?

【问题讨论】:

    标签: regex google-sheets-formula match substitution google-query-language


    【解决方案1】:

    尝试:

    =QUERY(A:A; "select A where A matches 'Property 2|Property 5'"; )
    

    【讨论】:

    • 杰出的!我知道必须有某种方式,=substitute() 可以用竖线替换逗号。谢谢!
    猜你喜欢
    • 2018-10-27
    • 1970-01-01
    • 2011-05-14
    • 2014-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-30
    相关资源
    最近更新 更多