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)
 3 TABLE JOIN

Author  Topic 

oahu9872
Posting Yak Master

112 Posts

Posted - 2005-10-06 : 09:07:15
I am working on a site search function that looks into our database. I need it to look for data that is set up using three different tables...

My site has a calendar of events that come out of the database. They are tied to a Client hosting the event, so the record displays when the ID's match up in the Events and Client tables. Along with that event, there is an advertisement, which comes from the Ads table. So my important fields here are...

tblEvents - ClientID and OrderID
tblClient - Client ID
tblAds - OrderID and AdText

So I need to search in the AdText field where tblEvents ClientID = tblClient ClientID and tblEvents OrderID = tblAds OrderID.

I hope I explained this clearly. Thanks.


madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-06 : 09:11:06
Select A.AdText from tblEvents TE inner join tblClient Tc on TE.ClientID = TC.ClientID inner join tblAds A on A.OrderID = TE.OrderID

Madhivanan

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

oahu9872
Posting Yak Master

112 Posts

Posted - 2005-10-06 : 09:14:23
Great, thanks.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-06 : 09:17:48
Look for Joins in Books On Line, SQL Server help file to know more about Joins

Madhivanan

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

- Advertisement -