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 2005 Forums
 Transact-SQL (2005)
 Another Join

Author  Topic 

Zath
Constraint Violating Yak Guru

298 Posts

Posted - 2010-11-01 : 17:11:02

I'm stuck on this one.

I have a table, let's call it TableOne
I want everything from that table.
Primary key is a number.
Name is a varchar

There is a Partner table, call it TablePartner
Primary key is a number.
PartnerName is a varchar

I have a reference table. Let's call it TableRef
Primary key is a number
Col 1 is an int that references TablePartner PK
Col 2 is an int that references TableOne PK

Again, I want everything from TableOne and need to have something back from TableRef to tell me that Name from TableOne is active, that is it exists in TableRef.

The TablePartner just brings back the PartnerName
Having trouble with the Ref table.

Any suggestions?

Thanks,

Zath

Zath
Constraint Violating Yak Guru

298 Posts

Posted - 2010-11-01 : 18:31:16
Got it working!

Had to use a CASE and WHEN EXISTS...
Go to Top of Page
   

- Advertisement -