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? Link to comment https://forums.phpfreaks.com/topic/119616-using-match-against-with-unions/ 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. Link to comment https://forums.phpfreaks.com/topic/119616-using-match-against-with-unions/#findComment-616431 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. Link to comment https://forums.phpfreaks.com/topic/119616-using-match-against-with-unions/#findComment-616663 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. Link to comment https://forums.phpfreaks.com/topic/119616-using-match-against-with-unions/#findComment-616694 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.