【发布时间】:2011-07-24 17:40:01
【问题描述】:
基本上和我的other thread 相同的问题!
我有一个 db 表,我需要编写一个查询,该查询将根据字符串的部分匹配返回结果。
Example:
DB field: abc
Search term: 123abc
i.e. I want given 123abc for it to return the row that has the abc field in it!
My attempt:
SELECT mood from users where '$searchTerm' like '%' || dbField
这样的事情有可能吗?
嗯,基本上我正在尝试将数字与搜索词 la77740985 匹配
id | mood | numberfield
==== ===== ============
1 bad '77740985'
2 good '77513755'
运行查询会返回两行!
注意:通配符只能在字符串的开头,换句话说,我希望搜索词以任何开头,但仍匹配数据库中基本上具有相同结尾的字符串。
【问题讨论】:
标签: sql sqlite select wildcard sql-like