If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > union all order by

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-12-07, 03:27
shashi_s shashi_s is offline
Registered User
 
Join Date: Apr 2007
Posts: 21
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?
Reply With Quote
  #2 (permalink)  
Old 04-12-07, 03:31
shashi_s shashi_s is offline
Registered User
 
Join Date: Apr 2007
Posts: 21
Please diregard...i was being dumb, a bit of further googling helped me out
i feel the pain
Reply With Quote
  #3 (permalink)  
Old 04-12-07, 08:42
aschk aschk is offline
Registered User
 
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?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On