我有一个表,其中一个字段包含诸如“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'
它返回第一行?
最佳答案
是的,如果您将模式更改为“like compatible”值,并反转 like 逻辑:
select * from pattern_table
where 'hey bobby' like replace(f_pattern, '*', '%')
关于mysql - 当模式在字段中时如何编写查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9253173/