Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am trying to make a search page return results from multiple table ordered by the keyword. The problem is the select statement gives a result sorted by the select statement and not by the keyword.

(
    SELECT live_cat.live_cname ,'cat' as type 
    FROM live_cat 
    WHERE match(live_cname) against('asir alroh') 
)
UNION 
(
    SELECT live_users.live_name ,'user' as type   
    FROM live_users 
    WHERE match(live_name)  against('asir alroh')
) 
UNION 
(
    SELECT live_tags.live_tag_name  ,'tag' as type  
    FROM live_tags 
    WHERE match(live_tag_name) against('asir alroh')
)

The result is like this:

|_live_name_______________|_type__|                     
|asir altag_______________|cat    |              
|asir alwlaw haja_________|cat    |               
|asir alroh_______________|user   |              
|asir altaggat____________|tag    |           
|asir alla tagar__________|tag    |  

I want it like this:

|_live_name_______________|_type__|  
|asir alroh_______________|user   |                             
|asir altag_______________|cat    |              
|asir alwlaw haja_________|cat    |                   
|asir altaggat____________|tag    |           
|asir alla tagar__________|tag    |        
share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.