Welcome to WebmasterWorld Guest from 54.145.44.134

Forum Moderators: open

Message Too Old, No Replies

MySQL fulltext +relevance query won't work

     

snowweb

11:12 am on Jul 16, 2008 (gmt 0)

5+ Year Member



I've been working on this all day and finally given up and decided to submitted it to the experts! I've already checked the manual but still can't make it work.

I'm trying to construct a query that will query multiple fields from a database table and will return just those results where the query string is found, in order of relevance.

I'm working in both PHP5 and MySQL5

This is what I have so far:


$query = "SELECT `list_id`, `business_name`, `name_first`, `name_middle`, `name_last`, `category`, `address_city`, `address_country`, `status`, MATCH ( `business_name` ,
`name_first` ,
`name_middle` ,
`name_last` ,
`address_1` ,
`address_2` ,
`address_3` ,
`address_city` ,
`address_state` ,
`address_zip` ,
`address_country` ,
`email` ,
`about_me` ,
`p_keywords` ) AGAINST ($string) AS relevancy FROM `directory` WHERE MATCH (`business_name` ,
`name_first` ,
`name_middle` ,
`name_last` ,
`address_1` ,
`address_2` ,
`address_3` ,
`address_city` ,
`address_state` ,
`address_zip` ,
`address_country` ,
`email` ,
`about_me` ,
`p_keywords`) AGAINST ($string ) AND status = 'active' ORDER BY relevancy ";

The above example returns no results, even though I know that the 4 letter term searched for, exists many times in the database fields searched.

Any help would be greatly appreciated.

Thanks guys

pete