spiceydog Posted August 14, 2008 Share Posted August 14, 2008 i need to MATCH () AGAINST... my entire query not just each seperate UNION... what do i do? This is a search query I am working with so here is the mysql_query: (SELECT * FROM albuminfo WHERE albumname LIKE '%$searchs%' GROUP BY albumname ORDER BY views LIMIT 10) UNION (SELECT * FROM albuminfo WHERE artist LIKE '%$searchs%' GROUP BY albumname ORDER BY views LIMIT 10) UNION (SELECT * FROM albuminfo WHERE track LIKE '%$searchs %' GROUP BY albumname ORDER BY views LIMIT 10) UNION (SELECT * FROM albuminfo WHERE keywords LIKE '%$searchs%' GROUP BY albumname ORDER BY views LIMIT 10) UNION (SELECT * FROM albuminfo WHERE user LIKE '%$searchs%' GROUP BY albumname ORDER BY views LIMIT 10) MATCH ($where) AGAINST ('$sarray' IN BOOLEAN MODE) LIMIT 0, 10 $searchs (which is an array) = Array ( [0] => korn [1] => leader [2] => follow [3] => the ) $sarray = +korn +leader +follow +the $where = user, albumname, artist, keywords, track The error message i am getting is this: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MATCH (user, albumname, artist, keywords, track) AGAINST ('+korn +leader +follow' at line 1 What do i do? Quote Link to comment Share on other sites More sharing options...
fenway Posted August 14, 2008 Share Posted August 14, 2008 You can't do that, because you can't index across tables. Quote Link to comment Share on other sites More sharing options...
spiceydog Posted August 14, 2008 Author Share Posted August 14, 2008 But the only table I am using is albuminfo... There has to be a way to do what Im trying.. I want results ONLY to appear if all of the words in the array exist somewhere in the row. Quote Link to comment Share on other sites More sharing options...
Hooker Posted August 14, 2008 Share Posted August 14, 2008 SELECT * FROM albuminfo WHERE MATCH (user,albumname,artist,keywords,track) AGAINST ('$sarray' IN BOOLEAN MODE); Also while you're using the operator + for the words in your input array means mysql is looking for records that match ALL the words. 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.