To offer a web site search facility, the pattern matching function [ select * from table where title like %news%] is often used, only for a lack of knowledge of Mysqls’ natural language query feature. Like Google.com, the optimum is to provide your users with a search feature whereby users type anything, a single word, or a natural language phrase [e.g. iphone 3gs available in san francisco].  Here’s how to set it up in Mysql.

1. create your table
create table as always – example fields:  title varchar(80), description longtext.

2. add the full text index via SQL or using a tool like navicat
alter table add fulltext(title,longtext)

3. A tip: keep in mind, you can’t just add a single record and run a test search.  Several records must be present in the table for the keyword matching facility to work.

For more information, check out mysql.com reference documentation.

May 4, 2009 · Posted in Development, Mysql Php  
    


ÍÕÑí ÔÈÇÈ áíÈíÇ ÔÇÊ ÕæÑ ÊæÈíßÇÊ ãäÊÏíÇÊ íæÊíæÈ ÕæÑ ÓíÇÑÇÊ ÝÓÇÊíä Ïáíá ÇáãæÇÞÚ