We help IT Professionals succeed at work.

Need to query to join a one table to another table. Problem is that the other table has Foriegn key fields that I need included as well.

244 Views
Last Modified: 2010-03-19
Hi, I am currently extracting information from a sql database into an excel spreedsheet. I am needing the information to be placed into first normal form, which leads me to this current issue. I need to be able to query many tables and draw out information from all of them. My problem is that the second table that i want to join  has FK fields which reference other tables. I need to have the FK columns updated with data from the other tables and then joined onto the first table.  

I can currently do this sepeartely with two seperate querys. Problem is joining those querys so that the information in the other tables is all drawn together.
e.g
tableA
tableaID PK
column1
column2
column3

tableB
tablebID PK
tableaID FK
Column4
column5
tableCIDFK

tableC
tablecIDPK
column6
column7

select * from tableA
 left outer join on tableA.tableaid = tableB.tableaID;

so that will link all the data from tableB to tableA.

select * from tableB
 left outer join on tableB.tableCid = tableC.tableCID;
And that will draw all the information from tableB and tableC.

But unable join both querys?

How is it possible to do a query which selects all the information from TableA and joins the related information from tableB and tableC?
Comment
Watch Question

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Yes this does seem to work, i tried this before and got errors. However it appears to all be working ok.
Thanks.

Commented:
glad to be of help, thanx for the grade.

Ed.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.