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 > Database Server Software > Sybase > sub-query in FROM clause

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-18-10, 02:19
alirulez999 alirulez999 is offline
Registered User
 
Join Date: Jan 2010
Posts: 25
sub-query in FROM clause

hi,

select sub.*
from
(
select a
from
table1

union all

select a
from
table2
)sub

this query gives error in sybase 12.0. Whereas when the same query was executed in sybase 15 version, it works fine. This says that 12.0 does not support sub-query in FROM clause.

Any other alternative to achieve this in sybase 12.0

Got stuck, please help.
Reply With Quote
  #2 (permalink)  
Old 02-18-10, 04:14
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by alirulez999 View Post
Any other alternative to achieve this in sybase 12.0
Code:
SELECT a
  FROM table1
UNION ALL
SELECT a
  FROM table2
you don't need to use a subquery in the FROM clause for this query
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 02-18-10, 06:45
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
A derived table is similar to a view
So in pre 12.5 versions;
Create a view of the union and then select from the view
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