Jump to content

Using MATCH (...) AGAINST (...) with UNIONs!?


spiceydog

Recommended Posts

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
Share on other sites

  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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.