Database Articles
  Home arrow Database Articles arrow Page 3 - Full Text Searches and Strings
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Forums Sitemap 
Dedicated Servers  
Download TestComplete 
JMSL Numerical Library 
IBM® developerWorks
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE ARTICLES

Full Text Searches and Strings
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2007-09-27

    Table of Contents:
  • Full Text Searches and Strings
  • 5.17 Requiring or Excluding FULLTEXT Search Words
  • Another Solution
  • 5.18 Performing Phrase Searches with a FULLTEXT Index

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Full Text Searches and Strings - Another Solution


    (Page 3 of 4 )

    Another way to require multiple words is with a Boolean mode search. To do this, precede each word in the search string by a + character and add IN BOOLEAN MODE after the string:

      mysql> SELECT COUNT(*) FROM kjv
         
    -> WHERE MATCH(vtext) AGAINST('+David +Goliath' IN BOOLEAN MODE)
      +----------+
      | COUNT(*) |
      +----------+
      |        2 |
      +----------+

    Boolean mode searches also allow you to exclude words. Just precede any disallowed word by a -character. The following queries select kjv rows containing the name David but not Goliath, or vice versa:

      mysql> SELECT COUNT(*) FROM kjv
         -> WHERE MATCH(vtext) AGAINST('+David -Goliath' IN BOOLEAN MODE)
      +----------+
      | COUNT(*) |
      +----------+
      |      928 |
      +----------+
      mysql> SELECT COUNT(*) FROM kjv
         
    -> WHERE MATCH(vtext) AGAINST('-David +Goliath' IN BOOLEAN MODE)
      +----------+
      | COUNT(*) |
      +----------+
      |        4 |
      +----------+

    Another useful special character in Boolean searches is *; when appended to a search word, it acts as a wildcard operator. The following statement finds rows containing not only whirl, but also words such as whirls, whirleth, and whirlwind:

      mysql> SELECT COUNT(*) FROM kjv
         -> WHERE MATCH(vtext) AGAINST('whirl*' IN BOOLEAN MODE);
      +----------+
      | COUNT(*) |
      +----------+
      |       28 |
      +----------+

    For a complete list of Boolean FULLTEXT operators, see the MySQL Reference Manual.

    More Database Articles Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "MySQL Cookbook, Second Edition," published...
     

    Buy this book now. This article is excerpted from chapter five of the MySQL Cookbook, Second Edition, written by Paul DuBois (O'Reilly; ISBN: 059652708X). Check it out today at your favorite bookstore. Buy this book now.

    DATABASE ARTICLES ARTICLES

    - More on Query Optimization for Oracle Databa...
    - Query Optimization in Oracle
    - Clusters and Other Data Structures for Oracle
    - Using Indexes with an Oracle Database
    - The Basics of Data Structures in Oracle
    - Oracle Data Structures
    - Best Practices for PL/SQL Variables
    - What`s Code Without Variables?
    - Clauses, Sorting, and SQL Queries
    - The From Clause and SQL Queries
    - Query Primer
    - Full Text Searches and Strings
    - Searching with Strings
    - Pattern Matching with Strings
    - Working with Cases of Strings






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway