Results 1 to 2 of 2

Thread: Sorting by table

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    1,712
    Thanks
    82
    Thanked 90 Times in 88 Posts

    Default Sorting by table

    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?
    Last edited by james438; 05-02-2010 at 08:00 PM.
    To choose the lesser of two evils is still to choose evil. My personal site

  2. #2
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    1,712
    Thanks
    82
    Thanked 90 Times in 88 Posts

    Default

    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
    To choose the lesser of two evils is still to choose evil. My personal site

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •