随便举个例子
定义关键字符串 str
select * from table_name where col_a like '%str%' or col_b like '%str%'
或者
select * from table_name where col_a like '%str%' and col_b like '%str%'
%是通配符,代表0-n个任意字符
如果你要找到开头是 xxx的字符串,应该写 like 'xxx%'
结尾是xxx的字符串 like '%xxx'
含有xxx的字符串 like '%xxx%'
注意,如果字段有索引,只有like 'xxx%'能正确使用到索引
SELECT * from sys_food where CONCAT(foodName,factoryName) like '%白%'