Hi, I'm trying to query two unrelated tables (but retrieve related date). I've done this previously as 2 separate queries, but I'm trying to reduce the number of queries to increase performance. The 2 queries I use, are match queries (in Boolean Mode). I'm not an expert, but I'm trying to get this to perform as well as it can, and have read Match & Boolean Mode for searching over text columns is probably what I should be using. The problem I'm having is that I can order by one score but not the other: SELECT URL, SUM, Title, 'dummy1', 'dummy2', 'dummy3', 'dummy4', MATCH(TAG,SUM,Title) AGAINST ('Landlord') as RelevanceA FROM rft_searchlawssum WHERE MATCH (TAG,SUM,Title) AGAINST('Landlord' IN BOOLEAN MODE) UNION ALL SELECT g.URL as gURL, p.message AS pmessage, p.subject as psubject, g.idtype as gidtype, g.id as gid, p.pid as ppid, p.tid as ptid, MATCH(p.message,p.subject) AGAINST ('Landlord') as RelevanceB FROM mybb_google_seo g LEFT JOIN mybb_posts p ON g.id = p.tid WHERE MATCH(p.message,p.subject) AGAINST('Landlord' IN BOOLEAN MODE) AND g.idtype ='4' ORDER BY RelevanceA, RelavanceB DESC Code (markup): If I drop the RelavanceB this works, but with the RelavanceB I get: #1054 - Unknown column 'RelevanceB' in 'order clause' Any idea why I cant use RelavanceB in my order clause? I've re-arranged it, but have the same issue: SELECT g.URL as gURL, p.message AS pmessage, p.subject as psubject, g.idtype as gidtype, g.id as gid, p.pid as ppid, p.tid as ptid, MATCH(p.message,p.subject) AGAINST ('Landlord') as RelevanceB FROM mybb_google_seo g LEFT JOIN mybb_posts p ON g.id = p.tid WHERE MATCH(p.message,p.subject) AGAINST('Landlord' IN BOOLEAN MODE) AND g.idtype ='4' UNION ALL SELECT URL, SUM, Title, 'dummy1', 'dummy2', 'dummy3', 'dummy4', MATCH(TAG,SUM,Title) AGAINST ('Landlord') as RelevanceA FROM rft_searchlawssum WHERE MATCH (TAG,SUM,Title) AGAINST('Landlord' IN BOOLEAN MODE) ORDER BY RelevanceB DESC Code (markup): I now cant order by RelevanceA
I think you spelled it different in two cases in the alias it is "RelevanceB" in the order by it is "RelavanceB" notice the different spelling This should fix it