Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2007
    Posts
    21

    Unanswered: union all order by

    HI,

    got this sql query..which is a follow up from my prev thread....
    select * from A where A.id < 1000 union all select * from A where A.id > 5000
    order by A.id

    this gives me an error of an invalid order by

    i need to use the "union" is there a way to order the result?

  2. #2
    Join Date
    Apr 2007
    Posts
    21
    Please diregard...i was being dumb, a bit of further googling helped me out
    i feel the pain

  3. #3
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    LOL, i hope you used an OR statement in your where clause instead?
    Just for clarity I will rewrite your query :
    Code:
    SELECT *
    FROM <table> A
    WHERE (A.id < 1000) 
    OR (A.id > 5000)
    ORDER BY A.id
    Incidently; why do you "need" to use the union clause?

Posting Permissions

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