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
 Transact-SQL (2000)
 prob with 2 tables inner join

Author  Topic 

bilencekic
Posting Yak Master

121 Posts

Posted - 2006-04-02 : 08:19:43
I have a table names Product_1 and Product_2
but in these tables there are products that have same ProductID
i want to get the Product_2's products that doenst exists on Product_1
so which query must i use ?
right join or else ?

MS BLESS US

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-04-02 : 08:48:26
will this do?

select t2.*
from Product_2 t2 left join Product_1 t1 on t1.ProductID = t2.ProductID
where t1.ProductID is null



Go with the flow & have fun! Else fight the flow
Blog thingie: [URL="http://weblogs.sqlteam.com/mladenp"]
Go to Top of Page

bilencekic
Posting Yak Master

121 Posts

Posted - 2006-04-02 : 09:00:42
ok man :D thx very much
that query is what i want

MS BLESS US
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-03 : 02:28:10
Other method

Select * from Product_2 P2 where not exists
(select * from Product_1 where Product_id=P2.Product_id)

Madhivanan

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

- Advertisement -