Precede each word in the search string with a + character and add IN BOOLEAN MODE after the string : Boolean Search « FullText Search « SQL / MySQL






Precede each word in the search string with a + character and add IN BOOLEAN MODE after the string

     
mysql>
mysql> CREATE TABLE mytable
    -> (
    ->     bsect ENUM('O','N') NOT NULL, # book section (testament)
    ->     bname VARCHAR(20) NOT NULL, # book name
    ->     bnum TINYINT UNSIGNED NOT NULL, # book number
    ->     cnum TINYINT UNSIGNED NOT NULL, # chapter number
    ->     vnum TINYINT UNSIGNED NOT NULL, # verse number
    ->     vtext TEXT NOT NULL # text of verse
    -> ) TYPE = MyISAM;
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql>
mysql> ALTER TABLE mytable ADD FULLTEXT (vtext);
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql>
mysql>
mysql> SELECT COUNT(*) FROM mytable WHERE MATCH(vtext) AGAINST('+David +Goliath' IN BOOLEAN MODE);
+----------+
| COUNT(*) |
+----------+
|        0 |
+----------+
1 row in set (0.00 sec)

mysql>
mysql> drop table mytable;
Query OK, 0 rows affected (0.00 sec)

   
    
    
    
    
  








Related examples in the same category

1.Overview of Boolean Search Operators
2.Boolean Search Expressions (IN BOOLEAN MODE)
3.Boolean mode searches also allow you to exclude words.
4.FULLTEXT searching supports phrase searching in Boolean mode.
5.In boolean mode
6.Quotation in boolean mode
7.* in boolean mode
8.Boolean Full-Text Searches