也不起作用.如何纠正? 解决方案 您可以使用 REGEXP 运算符:SELECT * FROM mytable WHERE 'mystring' REGEXP CONCAT('[[:<:]]', column_name, '[[:>:]]');但是请注意,这慢.您最好使用 MySQL 的 FULLTEXT 搜索功能 如果您关心单词.或者做一个普通的 InStr() 检查然后过滤结果.i want to check if a string contains a field value as a substring or not.select * from mytable where instr("mystring", column_name);but this does not search on word boundaries.select * from mytable where instr("mystring", concat('[[:<:]]',column_name,'[[:>:]]');does not work either. how to correct this? 解决方案 You can do this using the REGEXP operator:SELECT * FROM mytable WHERE 'mystring' REGEXP CONCAT('[[:<:]]', column_name, '[[:>:]]');Note, however, that this is slow. You might be best off using the MySQL's FULLTEXT search feature if you care about words. Or do a normal InStr() check then filter the results. 这篇关于mysql: instr 指定单词边界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-09 23:15