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
 SQL Server Development (2000)
 querying a result recordset

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-08-13 : 13:08:21
jane writes "Hi Gurus,
I know what records I want from the db, but I just don't know how to form the queries to retrieve it.

Basically, I need info from 3 tables:

contact_tbl
business_tbl
history_tbl

the relationship between contact_tbl and business_tbl is 1 to many

the relationship between business_tbl and history_tbl is 1 to many

I first need to retrieve all the business records that pertain to a certain contact and then from THAT recordset I need to retrieve all the history items that pertain to a certain business

Please help!

Thank you,
Jane"

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-08-13 : 13:41:54
Look up JOIN in Books Online.

It's gonna end up being something like ...

select
<column list>
from
business_tbl b
inner join contact_tbl c
on c.<primary key> = b.<foreign key>
inner join history_tbl h
on b.<primary key> = h.<foreign key>

 
Is the "_tbl" naming convention really necessary?

Jay White
{0}
Go to Top of Page
   

- Advertisement -