We Recommend

SQL Cookbook SQL Cookbook
Written in O'Reilly's popular Problem/Solution/Discussion style, the SQL Cookbook is sure to please. Anthony's credo is: "When it comes down to it, we all go to work, we all have bills to pay, and we all want to go home at a reasonable time and enjoy what's still available of our days." The SQL Cookbook moves quickly from problem to solution, saving you time each step of the way.


Posted By

valcartei on 07/11/07


Tagged

search fulltext indexing


Versions (?)


search


Published in: SQL 


  1. //creation of the INDEX:
  2. //this means that when searching the string will be looked FOR IN the the 3 FIELDS specified within the brakets.
  3.  
  4. ALTER TABLE fulltext_sample ADD FULLTEXT(username,first_name,last_name)
  5.  
  6. //searching:
  7. //this searches any word WHERE $mystring IS contained (that's why the *) in the 3 cols
  8. SELECT * FROM fulltext_sample WHERE MATCH(username,first_name,last_name) AGAINST('*".$mystring."*' IN BOOLEAN MODE);

Report this snippet 

You need to login to post a comment.