Like 的 SQL 替代方案返回精确匹配(即?
我需要它返回精确匹配,同时仍然能够使用通配符。
因此,当搜索“carb”时,我想返回一个值,例如“Racing Carb” 但我不想返回诸如“赛车化油器”之类的值,
这就是我现在拥有的......
SELECT I.SKU, I.[Description]
FROM Inventory AS I
INNER JOIN MisspelledWords AS M
ON I.[Description] like '%' + M.[Word] + '%'
I need this to return an exact match while still being able to use the wild card.
So when searching for 'carb' i want to return a value such as 'Racing Carb'
but i do not want to return a value such as 'Racing Carburetor'
This is what I have now...
SELECT I.SKU, I.[Description]
FROM Inventory AS I
INNER JOIN MisspelledWords AS M
ON I.[Description] like '%' + M.[Word] + '%'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个:
更新
不返回任何内容,这意味着未选择“赛车化油器”。
更新 2
此更新涉及边缘案例。
Try this:
Update
Returns nothing, which means that 'Racing Carburator' isn't getting selected.
Update 2
This one deals with marginal cases.
不知道mysql或ms-sql,但你可以在oracle中使用regexp_like函数。
Dunno about mysql or ms-sql, but you can use regexp_like function in oracle.
尝试
(field like '%carb' or field like '%carb %')
这将匹配
racing carb
和carb for racing
但不匹配 <代码>赛车化油器或赛车化油器
。try
(field like '%carb' or field like '%carb %')
This will match
racing carb
andcarb for racing
but notracing carburator
orcarburator for racing
.