当模式位于字段中时如何编写查询
我有一个表,其中字段包含“hey *”或“%test%”等模式。 像这样:
Id - f_pattern - f_Respond
1 - 'hey *' - 'hello there'
2 - 'how are you *' - 'am fine'
我是否可以像这样编写查询:
select * from table where f_pattern like 'hey bobby'
它返回第一行?
I've got a table in which a field contains pattern like 'hey *' or '%test%'.
Like this :
Id - f_pattern - f_Respond
1 - 'hey *' - 'hello there'
2 - 'how are you *' - 'am fine'
Is is possible that i write query like this :
select * from table where f_pattern like 'hey bobby'
and it returns the first row ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,如果您将模式更改为“类似兼容”值,并反转类似逻辑:
Yes, if you change your patterns to "like compatible" values, and reverse the like logic:
你试过
//编辑
它让我惊讶,但这有效:
请参阅: http://dev.mysql.com/doc/refman/5.0/en/pattern-matching.html
have you tried
//edit
it surprised me, but this works:
see: http://dev.mysql.com/doc/refman/5.0/en/pattern-matching.html