google-sheets - 使用 Google 表格查询功能进行字符串比较
问题描述
我无法理解为什么我的查询不起作用。结果始终为空,除非删除 C=D 然后我得到一个 ID 列表。该公式将用于名为 IDS 的新工作表,并从 Threads 中提取数据。我的查询是:
=QUERY(Threads!A:D,"select A where B='No Label'and C=D",-1)
我试图查询的表看起来像这样:
| IDS (A) |Labels(B) |Email List(C) | Matching Emails(D)|
|----------------|----------|-------------------|-------------------|
|179cd3g671269f69|No Label |pat@rus.com |bro@rus.com |
|179cd83p7a655449|No Label |SCP.admi@pab.com |mike@rus.com |
|179cb58p79236216|No Label |SCP.admi@pab.com |pat@rus.com |
|179c9er26ca777c8|No Label |dar@rus.com |sed@rus.com |
|179c8l3c5b46e4ga|No Label |dar@rus.com |will@rus.com |
|179c8oe73a13d487|No Label |pat@rus.com |dar@rus.com |
解决方案
它不起作用,因为当 Col C 中的值与 Col D 相同时没有行。
如果要检查 Col C 中的每一行与 Col D 中的任何值,请使用:
=QUERY(Threads!A:D,"select A where B='No Label' and C matches '"&textjoin("|",true,D2:D)&"' ",1)
textjoin("|",true,D2:D)
带回 Col D 中的所有值:
bro@rus.com|mike@rus.com|pat@rus.com|sed@rus.com|will@rus.com|dar@rus.com|pat@rus.com
|
分隔符的作用是OR
,所以bro@rus.com OR mike@rus.com...
如果需要,如果将来出现重复项,您可以带回一个唯一列表:
textjoin("|",true,unique(D2:D))
所以公式是:
=QUERY(Threads!A:D,"select A where B='No Label' and C matches '"&textjoin("|",true,unique(D2:D))&"' ",1)
反过来进行检查(Col D 匹配 Col C):
=QUERY(Threads!A:D,"select A where B='No Label' and D matches '"&textjoin("|",true,unique(C2:C))&"' ",1)
推荐阅读
- linux-kernel - 内核崩溃后如何获取kdump?
- angular-cli - Angular CLI - ng serve --serve-path
- sql - Postgres 行级安全性不允许更新限制性选择策略
- r - r shiny - 使用 imageOutput() 和 renderImage() 绘制多个图像
- python - 如何在python中为乌龟制作闪烁效果?
- javascript - 将参数从 npm 构建脚本添加到 javascript 应用程序
- slack - 如何编辑我的 Slack 应用程序的“关于”页面?
- google-apps-script - 更新后使用旧部署
- c# - S3 标记错误 - 您提供的 TagValue 无效
- python - 如何在 Python 中返回字符串的最后一个字符?