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 Link to comment https://forums.phpfreaks.com/topic/73320-match-query-issue/ 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. Link to comment https://forums.phpfreaks.com/topic/73320-match-query-issue/#findComment-369920 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? Link to comment https://forums.phpfreaks.com/topic/73320-match-query-issue/#findComment-369927 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. Link to comment https://forums.phpfreaks.com/topic/73320-match-query-issue/#findComment-369933 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 Link to comment https://forums.phpfreaks.com/topic/73320-match-query-issue/#findComment-369939 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. Link to comment https://forums.phpfreaks.com/topic/73320-match-query-issue/#findComment-369996 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 ------------- Link to comment https://forums.phpfreaks.com/topic/73320-match-query-issue/#findComment-370099 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. Link to comment https://forums.phpfreaks.com/topic/73320-match-query-issue/#findComment-370659 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.