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
 Basic Select / Join Query

Author  Topic 

MatthewJapp
Starting Member

1 Post

Posted - 2012-04-12 : 10:27:07
I have 2 tables

Let's call them Table 1 and Table 2.

Table 1 has 10 fields

Table 2 has 10 fields

I need to bring back everything in table 2, and 1 column from Table 1 called product_typejoined on lets say product_id which exists in both tables.

How would this look in SQL 2008.

First step of a long journey. Thanks guys (or girls)

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2012-04-12 : 11:12:34
select b.*,a.product_type from table1 a
inner join table2 b
where a.product_id=b.product_id;

Hope this works.
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2012-04-12 : 11:21:46
Small correction:

select b.*, a.product_type
from table1 a
inner join
table2 b
On a.product_id = b.product_id;
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2012-04-12 : 12:17:07
Ohh thanks Russell...continuous coding in pl/sql now a days...
Go to Top of Page
   

- Advertisement -