【发布时间】:2017-04-27 19:47:39
【问题描述】:
我必须在 SQLITE 的多个列中搜索单个字符串,但我无法获得结果,我正在使用以下查询进行搜索:
Select *
From MyTable
Where (col1 || '--' || col2) like '%abc xyz 123%'
假设我在 col1 中有 'abc',在 col2 中有 'xyz 123'。 p>
任何帮助。
【问题讨论】:
-
试试这个:Select *from yourtable where col1 like 'searchstring' or col2 like 'searchstring' etc.\
-
您的查询会进行搜索,但在上述情况下会失败。
-
你怎么能说它会失败。你试过了吗,它不会失败。您需要为 col 传递不同的字符串。 Select * From Yourtable where col1 like 'abc' or col2 like 'xyz 123'.
-
我不想分开两个字符串,我可以知道哪个字符串是 col1 或 col2 的一部分,因为我必须搜索两个列的完整字符串。