sqlite - 查询以在整个表上搜索关键字
问题描述
我有下表:
当我执行查询时:
SELECT Description, Solution, ReportBy from KMS where Description or Effect or Cause or Check1 or Solution or ReportBy like '%test%'
这是结果:
我可以预期车道 2、3、4、6、7、8、9 和 10 是结果,我做错了什么?
问候, FMendonça
解决方案
这个查询
SELECT Description, Solution, ReportBy
from KMS
where Description
or Effect
or Cause
or Check1
or Solution
or ReportBy like '%test%'
将只返回具有的行的结果
ReportBy like %test%'
1
在任何其他列中
那是因为where Description
本质上是一个布尔测试。如果要检查多列中的值,则必须分别检查每一列,例如:
WHERE Description like '%test%'
OR Effect like '%test%'
.
.
OR ReportBy like '%test%'
推荐阅读
- python - 导入和使用年、月、日值的 Python 日期时间问题
- docker - 从 Minikube 集群访问本地机器上运行的 Docker 容器
- sql - 如何将隐式连接重写为显式连接?
- c# - ConnectAsync() 在 C# Visual Studio 中永远不会完成
- python - 在 Python 中运行 xgboost 的问题
- swift - 我可以使用 Swift 5 构建用 Swift 3 编写的目标吗
- sql - Sqlite 获取此表的最新记录
- git - 先推后拉 - 丢失的更改
- testing - 如何测试 Rust 程序传递给另一个程序的参数?
- wordpress - 使用 wp_dropdown_categories 后重置数据和查询