HuyPV
Thursday, September 17, 2009
mysql -u root -p
use test
create table article(id int auto_increment primary key, title varchar(255), content text);
alter table article add fulltext (title, content);
show index in article where index_type='fulltext';
insert into article(title, content) values ('My house is very nice', 'My house is in Tokyo. My house is nice'), ('Your house is very old', 'Your house is in London. Your house is very expensive');
select * from article where match(title, content) against('+house -expensive' IN BOOLEAN MODE);
+----+-----------------------+----------------------------------------+
| id | title | content |
+----+-----------------------+----------------------------------------+
| 1 | My house is very nice | My house is in Tokyo. My house is nice |
+----+-----------------------+----------------------------------------+
1 row in set (0.00 sec)
Title:
MySQL - fulltext search example
Description:
mysql -u root -p use test create table article(id int auto_increment primary key, title varchar(255), content text); alter table article add...
...
Rating:
4