June 19, 2009 at 1:38 pm
Hello - I am using 4 tables; tblOne, tblTwo, tblThree, and tblFour. All of these tables have a common column called 'BK_ID'. Based on this column name, I'd like to pull the following data:
SELECT BK_ID, Cburg, Hburg,Bmac,Soda
From tblOne, I need Cburg, where BK_ID in tbleOne = BK_ID in tbleTne
From tblTwo, I need Hburg, where BK_ID in tbleOne = BK_ID in tbleTwo
From tblThree, I need Bmac, where BK_ID in tbleOne = BK_ID in tbleThree
From tblFour, I need Soda, where BK_ID in tbleOne = BK_ID in tbleFour
I appreciate your help. Thank you.
June 19, 2009 at 2:22 pm
check out this quick tutorial on how to do joins. http://www.w3schools.com/sql/sql_join_inner.asp%5B/url%5D
should be enough info to get you want you want.
June 19, 2009 at 2:59 pm
Something like below should work:
select t1.Cburg,t2.Hburg,t3.Bmac,t4.Soda
from table1 t1 inner join table2 t2 on t1.BK_ID=t2.BK_ID
inner join table3 t3 on t2.BK_ID=t3.BK_ID
inner join table4 on t3.BK_ID=t4.BK_ID
June 21, 2009 at 3:56 am
From tblOne, I need Cburg, where BK_ID in tbleOne = BK_ID in tbleTne
From tblTwo, I need Hburg, where BK_ID in tbleOne = BK_ID in tbleTwo
From tblThree, I need Bmac, where BK_ID in tbleOne = BK_ID in tbleThree
From tblFour, I need Soda, where BK_ID in tbleOne = BK_ID in tbleFour
query:
SELECT tblOne.BK_ID, tblOne.Cburg, tblTwo.Hburg,tblThree.Bmac,tblFour.Soda
from From tblOne
inner join tblTwo on tblOne.BK_ID=tblTwo.BK_ID
inner join tblThree on tblTwo.BK_ID=tblThree.BK_ID
inner join tblFouron tblThree.BK_ID=tblFour.BK_ID
June 22, 2009 at 6:25 am
No! Without tables structure and some sample data you don't get the correct answer, anyway you should follow the rules to post the problem and it is describe in my signature!
Have a nice day!
😉
June 22, 2009 at 6:27 am
Thanks for the people who are posting the solutions and it might be ok, but if you want the best solution for you problem ...see my signature!
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply