Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 alias joined table

Author  Topic 

luciffer
Starting Member

8 Posts

Posted - 2004-07-06 : 19:52:28
hi all,

I'm new to SQL Server, have been using Oracle.

I can't seem to find a way to alias the resulting columns of joined tables. In oracle this is damn easy.

select joined_tables.*
from (tableA inner join tableB on tableA.tableB_ID = tableB.ID) joined_tables;

I can only alias both tables in the join which does nothing. How do you alias the result of the join????

Thanks.

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2004-07-06 : 19:55:17
In SQL Server you use a derived table:

SELECT c.*
FROM
(
SELECT a.col1,a.col2,a.colN, b.col1,b.col2,b.colN
FROM tableA a
INNER JOIN tableB b on b.colN=a.colN
) c
Go to Top of Page

luciffer
Starting Member

8 Posts

Posted - 2004-07-06 : 20:47:58
Thanks, i was affraid of that
Go to Top of Page
   

- Advertisement -