【求解】MySQL模糊查询问题

  • id name
  • 1 宇文成空呼延浩特
  • 2 呼和浩特宇文成空
  • 3 无名氏 怎么根据“文成浩特”这个字符串查询到ID为1、2的两条数据? MySQL能实现吗?可以的话请大神贴出语句。要写函数的话恳请贴出详细code。 万分感谢!

为什么楼上全用AND...假如中间规定不允许断格,把中间的通配符取消就好了
SELECT *
FROM
test
where name like '%浩%特%' OR '%文%成%'

select *from 表名 where name LIKE ''%文成% goup by id;这样应该就可以了

select *from 表名 where name LIKE '%文成% and '%浩特%' goup by id;

select *from 表名 where name LIKE ''%文成浩特%

select * from 表名 where name LIKE '%文成%' and '%浩特%';