tags:

views:

39

answers:

3

Is there any way I can do a join between two tables where the resulting table has only the columns of the left table without the need to discriminate all the columns names in the select?

+2  A: 

You can do this:

Select LeftTable.*
From LeftTable
    Inner Join RightTable
        On LeftTable.Id = RightTable.Id
Raj More
Beat me by 3 seconds :-)
Dani
This works, but be aware that if this query is part of a view, any new columns added to LeftTable will not be selected by the view until the view is recompiled. (at least I've observed this behavior in MS SQL Server)
Michael Petito
A: 

Select T.* from tbl1 T, tbl2 J

Dani
`Select T.* from tbl1 T, tbl2 J` does not look like a join. It is a Cartesian product.
Raj More
I've just showed the T.* and ignore the rest of the statement, as it should been enough to understand :-)
Dani
A: 

You mean something like

Select t1.id, t1.name, t1.age FROM t1 INNER JOIN t2 ON t1.id = t2.id 
WHERE t2.Something = Something
Pace