I have the following query working but trying to add ORDER BY relevance DESC
. Can anyone tell me the proper syntax as I have no success putting that to work and receive no matching results:
$query =
"(SELECT postid as id, title as name, 'post' as type FROM post WHERE MATCH (title, content) AGAINST ('$keywords' IN BOOLEAN MODE))
UNION
(SELECT pdid as id, pdname as name, 'product' as type FROM product WHERE MATCH (pdname, pddesc, pddetail) AGAINST ('$keywords' IN BOOLEAN MODE))";
This is what I have tried:
$query =
"(SELECT postid as id, title as name, 'post' as type MATCH (title, content) AGAINST ('$keywords' IN BOOLEAN MODE) as relevance FROM post
WHERE MATCH (title, content) AGAINST ('$keywords' IN BOOLEAN MODE))
UNION
(SELECT pdid as id, pdname as name, 'product' as type MATCH (pdname, pddesc, pddetail) AGAINST ('$keywords' IN BOOLEAN MODE) as relevance FROM product
WHERE MATCH (pdname, pddesc, pddetail) AGAINST ('$keywords' IN BOOLEAN MODE))
ORDER BY relevance DESC
";