Log in

View Full Version : Resolved Sorting by table



james438
05-02-2010, 07:29 PM
Here is a query I want to use. It works fine. I was rather surprised that it worked the first time I tried it.

(select ID, title from anime WHERE (lcase( concat(cast(ID as char), summary, IFNULL(image,''))) LIKE '%term%' ))
UNION
(select ID, title from misc WHERE (lcase( concat(cast(ID as char), summary)) LIKE '%term%' ))
UNION
(select ID, title from manga WHERE (lcase( concat(cast(ID as char), summary, IFNULL(image,''))) LIKE '%term%' ))
order by ID asc limit 10
As you can see I am sorting by ID here, but how can I sort this by table then by ID or even just by table?

james438
05-02-2010, 08:00 PM
Silly me. Here is how the query would look if I want to sort by table and then by ID:


(select ID, title from anime_review WHERE (lcase( concat(cast(ID as char), summary, IFNULL(image,''))) LIKE '%term%' ) order by ID)
UNION
(select ID, title from misc WHERE (lcase( concat(cast(ID as char), summary)) LIKE '%term%' ) order by ID)
UNION
(select ID, title from manga_review WHERE (lcase( concat(cast(ID as char), summary, IFNULL(image,''))) LIKE '%term%' ) order by ID)
limit 10