首页  编辑  

简单全文搜索所有字段

Tags: /MySQL/   Date Created:
How to simple full text search all fields with a keyword?
如何在MySQL中,对一个关键字简单全文搜索所有字段?

解答:
select * from table where concat_ws(',', field1, field2, field3, .... fieldN) like "%Keyword%";
或者用正则表达式regular Express也可以:
select * from table where concat_ws(',', field1, field2, field3, ... fieldN) REGEXP "Keyword1|Keyword2|Keyword3";
上面的方法可以用OR的方式,匹配三个关键字!

It's the simplest way to do the full text search, but the performance is poor.
上面的方法很简单,但是性能比较差,不适合大量数据。