Ltj_bukem Posted October 15, 2007 Share Posted October 15, 2007 Hi, I am trying to create a search facility that looks through two fields in a table. The table is called song and the two fields are name, dance. So far I have the following $query = "SELECT name,dance FROM song WHERE MATCH name,dance AGAINST ('$search')"; This query gives no results, but If I search only one field I get a good response, it's when I try two that the problem arises. Cheer Quote Link to comment Share on other sites More sharing options...
kirk112 Posted October 15, 2007 Share Posted October 15, 2007 Try MATCH(name,dance) AGAINST Not sure if it makes a difference. Quote Link to comment Share on other sites More sharing options...
Ltj_bukem Posted October 15, 2007 Author Share Posted October 15, 2007 Cheers, Doesn't make ant difference though, both fields are set to FULLTEXT in the database & the search works when the query only has one field. I'm guessing that the syntax is wrong? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted October 15, 2007 Share Posted October 15, 2007 MATCH name, dance requires a match to both. If the record doesn't match BOTH, no result is returned. You may want an OR in there to match one OR the other. Quote Link to comment Share on other sites More sharing options...
Ltj_bukem Posted October 15, 2007 Author Share Posted October 15, 2007 This seems to work $query = "SELECT dance,name FROM song WHERE MATCH (dance) AGAINST ('$search') OR MATCH (name) AGAINST ('$search')"; Sometimes the user might type in a 3 letter word such as 'jig'. I know that there are some issues with words with less than 4 characters. I guess I could write some code to add a random letter to any word with 3 letters & hope that the search will pick it up. Thanks Quote Link to comment Share on other sites More sharing options...
fenway Posted October 15, 2007 Share Posted October 15, 2007 Yes, full-text indexing is rather limited... look at Lucene. Quote Link to comment Share on other sites More sharing options...
hamza Posted October 15, 2007 Share Posted October 15, 2007 try this one $query = " SELECT * FROM song WHERE dance = '$search' OR name '$search' ; i am sure it will work to. just try this. and reply me man than i will tell you something else about more on this ------------- Quote Link to comment Share on other sites More sharing options...
fenway Posted October 16, 2007 Share Posted October 16, 2007 try this one $query = " SELECT * FROM song WHERE dance = '$search' OR name '$search' ; More like: SELECT * FROM song WHERE dance LIKE '%$search%' OR name LIKE '%$search%' ; But that scales very poorly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.