选择显示字体大小

全文索引—contains语法

全文索引——contains 语法
我们通常在 where 子句中使用 contains ,就象这样:select * from table_name where contains(fulltext_column,'search contents')。

我们通过例子来学习,假设有表 students,其中的 address 是全文本检索的列。
1. 查询住址在北京的学生
select student_id,student_name
from students
where contains( address, 'beijing' )
remark: beijing是一个单词,要用单引号括起来。

2. 查询住址在河北省的学生
select student_id,student_name
from students
where contains( address, '"heibei province"' )
remark: hebei province是一个词组,在单引号里还要用双引号括起来。

3. 查询住址在河北省或北京的学生
select student_id,student_name
from students
where contains( address, '"heibei province" or beijing' )
remark: 可以指定逻辑操作符(包括 and ,and not,or )。

4. 查询有 '南京路' 字样的地址
select student_id,student_name
from students
where contains( address, 'nanjing near road' )
remark: 上面的查询将返回包含 'nanjing road','nanjing east road','nanjing west road' 等字样的地址。
          a near b,就表示条件: a 靠近 b。

5. 查询以 '湖' 开头的地址
select student_id,student_name
from students
where contains( address, '"hu*"' )
remark: 上面的查询将返回包含 'hubei','hunan' 等字样的地址。
          记住是 *,不是 %。

6. 类似加权的查询
select student_id,student_name
from students
where contains( address, 'isabout (city weight (.8), county wright (.4))' )
remark: isabout 是这种查询的关键字,weight 指定了一个介于 0~1之间的数,类似系数(我的理解)。表示不同条件有不同的侧重。

7. 单词的多态查询
select student_id,student_name
from students
where contains( address, 'formsof (inflectional,street)' )
remark: 查询将返回包含 'street','streets'等字样的地址。
         对于动词将返回它的不同的时态,如:dry,将返回 dry,dried,drying 等等。

以上例子都使用英文,不使用中文是因为有的查询方式中文不支持,而且我的计算机是英文系统。


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons