转自:
<p style="border:0px;line-height:1.7;color:rgb(51,51,51);font-size:16px;">
一个SELECT查询中的LIKE语句来执行这种查询,尽管这种方法可行,
<p style="border:0px;line-height:1.7;color:rgb(51,51);font-size:16px;">
但对于全文查找而言,这是一种效率极端低下的方法,尤其在处理大量数据的时候。
<p style="border:0px;line-height:1.7;color:rgb(51,51);font-size:16px;">
上面这句话 我是在网上看到的, 说得挺有道理的, mysql 本身提供了一种叫做全文搜索的技术吧,
<p style="border:0px;line-height:1.7;color:rgb(51,51);font-size:16px;">
不过这好像从后来的版本才有的, 比较旧的版本不支持,不过那是很早期的版本了,
<p class="runtimead" style="border:0px;text-align:center;line-height:1.7;color:rgb(51,51);font-size:16px;">
show indexes from articles;
+----------+------------+----------+--------------+-------------+
| Table??? | Non_unique | Key_name | Seq_in_index | Column_name |
+----------+------------+----------+--------------+-------------+
| articles |????????? 0 | PRIMARY? |??????????? 1 | id????????? |
| articles |????????? 1 | title??? |??????????? 1 | title?????? |
| articles |????????? 1 | title??? |??????????? 2 | body??????? |
+----------+------------+----------+--------------+-------------+
3 rows in set (0.01 sec)
select * from articles;
+----+-----------------------+------------------------------------------+
| id | title???????????????? | body???????????????????????????????????? |
+----+-----------------------+------------------------------------------+
|? 1 | MySQL Tutorial??????? | DBMS stands for DataBase ...???????????? |
|? 2 | How To Use MySQL Well | After you went through a ...???????????? |
|? 3 | Optimizing MySQL????? | In this tutorial we will show ...??????? |
|? 4 | 1001 MySQL Tricks???? | 1. Never run mysqld as root. 2. ...????? |
|? 5 | MySQL vs. YourSQL???? | In the following database comparison ... |
|? 6 | MySQL Security??????? | When configured properly,MySQL ...????? |
+----+-----------------------+------------------------------------------+
6 rows in set (0.00 sec)
SELECT * FROM articles
??? ->
??? ->???? WHERE MATCH (title,body) AGAINST ('database');
+----+-------------------+------------------------------------------+
| id | title???????????? | body???????????????????????????????????? |
+----+-------------------+------------------------------------------+
|? 5 | MySQL vs. YourSQL | In the following database comparison ... |
|? 1 | MySQL Tutorial??? | DBMS stands for DataBase ...???????????? |
+----+-------------------+------------------------------------------+
2 rows in set (0.00 sec)
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|