1.在mysql配置文件 my.ini里设置分词大小
ngram_token_size=2
2.给需要全文搜索的列添加FULLTEXT 引索
alter TABLE `table` add FULLTEXT KEY `ft_title` (`title`,`content`) WITH PARSER `ngram`
3.进行全文搜索
SELECT * FROM table
WHERE MATCH (title,content)
AGAINST ('搜索的关键字' IN NATURAL LANGUAGE MODE)
IN NATURAL LANGUAGE MODE为默认值可以不加
4.多表查询
表之间的查询用UNION ALL分开
SELECT * FROM table
WHERE MATCH (title,content)
AGAINST ('搜索的关键字' IN NATURAL LANGUAGE MODE)
UNION ALL
SELECT * FROM tables
WHERE MATCH (title,content)
AGAINST ('搜索的关键字' IN NATURAL LANGUAGE MODE)