大多数面向搜索引擎的网站都使用FULL-TEXT-SEARCH
. select
与...相比,它会更快LIKE
...我添加了一个示例和一些链接...我认为这对您很有用...在此全文搜索中也有一些条件...
第1步
CREATE TABLE articles (
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
title VARCHAR(200),
body TEXT,
FULLTEXT (title,body)
);
第2步
INSERT INTO articles (title,body) VALUES
('MySQL Tutorial','DBMS stands for DataBase ...'),
('How To Use MySQL Well','After you went through a ...'),
('Optimizing MySQL','In this tutorial we will show ...'),
('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'),
('MySQL vs. YourSQL','In the following database comparison ...'),
('MySQL Security','When configured properly, MySQL ...');
STEP:3
自然语言全文搜索:
SELECT * FROM articles
WHERE MATCH (title,body) AGAINST ('database');
布尔全文搜索
SELECT * FROM articles WHERE MATCH (title,body)
AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE);
浏览此链接
viralpatel.net、devzone.zend.com、sqlmag.com、colorado.edu、en.wikipedia.org