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)
 Joining 7 tables ???? HELP

Author  Topic 

svaibhav
Starting Member

1 Post

Posted - 2005-03-24 : 10:33:06
hey

i hav to join colums from 7 tables. the link is my data structure.

http://img222.exs.cx/img222/2331/19uu.jpg <----- data structure.

this is how it works : the user enters jobid. from job table i look for the client_type and if that is Insurer then i look into the Insurer table for client_id = Insr_id and look into Insured for Client2_id=Insd_id. if the client type is Insued then its the other way around. i know this structure is not the usuals that evry1 sees. but this is the structure that the company had and i hav to follow it. ill give u and example

for Job_id = 'J1' .... if Client_type = 'Insurer' ... then i do this -->
select * from Insurer where insr_id = client_id and Job_id = J1.
select * from Insured where insd_id = client2_id and Job_id = J1.

and then using J1 i retrive other relevant data.


data to be retrieved

job.job_id,job.job_date,job.job_desc,

insurer.insr_name,insurer.insr_add,insurer.insr_per1_name,insurer.insr_per1_tel,
insurer.insr_per1_mob,insurer.insr_per1_fax,insurer.insr_per2_name,insurer.insr_per2_tel,
insurer.insr_per2_mob,insurer.insr_per2_fax,

insured.insd_name,insured.insd_add,insured.insd_per1_name,insured.insd_per1_tel,
insured.insd_per1_mob,insured.insd_per1_fax,insured.insd_per2_name,insured.insd_per2_tel,insured.insd_per2_mob,insured.insd_per2_fax,

Party3.p3_name,Party3.p3_add,Party3.p3_per1_name,Party3.p3_per1_tel,Party3.p3_per1_mob,
Party3.p3_per1_fax,Party3.p3_per2_name,Party3.p3_per2_tel,Party3.p3_per2_mob,
Party3.p3_per2_fax,

surveyor_name,

Survey.vst_date,Survey.vst_Place,

report.rep_date,report.rep_date,

bill.total

these r the colums i need to retrieve ??? HELP ME PLZZZZZZZZZ

amachanic
SQL Server MVP

169 Posts

Posted - 2005-03-24 : 13:31:29
Can you post ACTUAL DDL, ACTUAL sample data (in the form of INSERT statements), and an example of the output you want, based on the sample data?

http://www.aspfaq.com/etiquette.asp?id=5006

Then it will be a lot easier to understand your question.



---
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-03-26 : 00:35:33
Adam: That's a great link

Kristen
Go to Top of Page
   

- Advertisement -