sql - 从列表中选择标题包含任何术语的行
问题描述
我有一个包含 product_id、product_url、email、product_title 等的数据集。
我想从 400 多个单词的列表中提取 product_title 包含某些形容词(Fabulous、Stunning、Rare、Amazing、Unique 等)的行。
如果不对每个单词执行单独的选择功能,我该如何做到这一点?我正在使用 SQLite
解决方案
您可以使用以下命令构造单个查询or
:
select t.*
from t
where t.title like '%Fabulous%' or
t.title like '%Stunning%' or
. . . ;
如果单词存储在单独的表中,您可以使用exists
:
select t.*
from t
where exists (select 1
from interesting_words iw
where t.title like '%' || iw.word || '%'
);
推荐阅读
- python - Python Selenium 单击按钮
- laravel - 在 Kubernetes 节点之间共享文件夹
- python - 如何在 django rest 框架中序列化多个查询集?
- javascript - 我正在尝试以编程方式从 anytrack.io 跟踪脚本中包含标签 {click_id} 并将其插入到链接中
- android - 接口回调错误..循环直到它崩溃 - KOTLIN
- r - 在 R 中打开 .dat 文件,类似于 python 中的 joblib
- javascript - 单击菜单项后如何关闭下拉菜单
- firebase - Firestore 拒绝在具有完全开放安全规则的 Web Worker 中添加操作(Web 应用程序)
- javascript - 如何在 console.log 语句中放置箭头函数,以便打印出箭头函数的返回值
- c# - .Net Core 5 - 身份用户协会?