全文用单列mysql搜索

时间:2012-06-12 19:05:40

标签: mysql

我是MySQL的新手。我正在尝试使用表格搜索,目前我正在使用关键字...但我喜欢实施全文搜索方法..

 CREATE TABLE art(
   id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
    body TEXT,
   FULLTEXT (body)
   ) ENGINE=MyISAM




INSERT INTO `art` (`id` , `body`) VALUES
(1,  'php coding and soluton'),
(2,  'java coding and soluton'),
(3, 'DBMS stands for DataBase ...'),
(4, 'After you went through a ...'),
(5, 'In this tutorial we will show ...'),
(6,  '1. Never run mysqld as root. 2. ...'),
(7, 'In the following database comparison ...'),
(8,  'When configured properly, MySQL ...');


SELECT * FROM art 
WHERE MATCH (body) AGAINST ('database'); 

我正在使用此代码实现Mysqlfulltext serach。但是我无法得到答案。我只在Body上使用全文搜索..是否可以使用请帮助我任何一个

1 个答案:

答案 0 :(得分:2)

这将起作用

select * from art where MATCH (body) AGAINST ('database')>0;

也看到了这个:

mysql> select MATCH (body) AGAINST ('database') from art;
+-----------------------------------+
| MATCH (body) AGAINST ('database') |
+-----------------------------------+
|                                 0 |
|                                 0 |
|                  1.06197416782379 |
|                                 0 |
|                                 0 |
|                                 0 |
|                  1.07391238212585 |
|                                 0 |
+-----------------------------------+
8 rows in set (0.00 sec)