Database Articles

  Home arrow Database Articles arrow Page 2 - Full Text Searches and Strings
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

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Full Text Searches and Strings - 5.17 Requiring or Excluding FULLTEXT Search Words


    (Page 2 of 4 )

    Problem

    You want to specifically require or disallow words in a FULLTEXT search.

    Solution

    Use a Boolean mode search.

    Discussion

    Normally, FULLTEXT searches return rows that contain any of the words in the search string, even if some of them are missing. For example, the following statement finds rows that contain either of the names David or Goliath:

      mysql> SELECT COUNT(*) FROM kjv
         
    -> WHERE MATCH(vtext) AGAINST('David Goliath');
      +----------+
      | COUNT(*) |
      +----------+
      |      934 |
      +----------+

    This behavior is undesirable if you want only rows that contain both words. One way to do this is to rewrite the statement to look for each word separately and join the conditions with AND:

      mysql> SELECT COUNT(*) FROM kjv
         -> WHERE MATCH(vtext) AGAINST('David')
         -> AND MATCH(vtext) AGAINST('Goliath');

      +----------+
      | COUNT(*) |
      +----------+
      |        2 |
      +----------+

    More Database Articles Articles
    More By O'Reilly Media

    blog comments powered by Disqus

    DATABASE ARTICLES ARTICLES

    - Completing a Book Inventory Management System
    - Uploading Images for a Book Inventory Manage...
    - Finishing the Add Book Story for a Book Inve...
    - Integration Testing for a Book Inventory Man...
    - User Stories for a Book Inventory Management...
    - Unit Testing a Book Inventory Management Sys...
    - Testing a Book Inventory Management System
    - Implementing Models for a Book Inventory Man...
    - Book Inventory Application: Publishers and B...
    - Handling Publishers in a Book Inventory Mana...
    - Publisher Administration for Book Inventory ...
    - Book Inventory Management
    - Using the SQL Reference Manual
    - Using Oracle SQL Developer with SQL Statemen...
    - Fixing Errors with Oracle SQL Developer


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 6 - Follow our Sitemap