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
 General SQL Server Forums
 New to SQL Server Programming
 getting all cols of 2 tables

Author  Topic 

bill_
Starting Member

38 Posts

Posted - 2009-09-08 : 09:26:38
If you're doing a query where 2 tables are joined by an inner join,

how do you get all the columns in both tables in the query without listing them 1 by 1?

There are some columns in both tables that have the same name including the ones the join would be based on.

ra.shinde
Posting Yak Master

103 Posts

Posted - 2009-09-08 : 09:30:49
select * from t1 inner join t2 on t1.col = t2.col.
But it is always good to specify the column names, which you want to select.

Rahul Shinde
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-08 : 09:31:02
quote:
Originally posted by bill_

If you're doing a query where 2 tables are joined by an inner join,

how do you get all the columns in both tables in the query without listing them 1 by 1?

There are some columns in both tables that have the same name including the ones the join would be based on.



What is wrong with typing the column names which is good practice?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -