SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Joining three tables
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

amurark
Yak Posting Veteran

India
53 Posts

Posted - 12/08/2012 :  00:30:50  Show Profile  Reply with Quote
pls help me
suppose there are threee tables A,B and C.
A has some records which are avalble in B table and B has some records which have in C table. But A and C dont have any connection.

How tojoin A, B and C.

For eg
one record of A -->1000256 is in B
B table have both--> 1000256, 1000930

one record of C --> 1000930 is in B


how to join three tables ?



Pls help me



Ankita

chadmat
The Chadinator

USA
1974 Posts

Posted - 12/08/2012 :  01:52:01  Show Profile  Visit chadmat's Homepage  Reply with Quote
SELECT * FROM
A JOIN B on A.id1 = b.id1
JOIN C ON B.id2 = C.id2

-Chad
Go to Top of Page

amurark
Yak Posting Veteran

India
53 Posts

Posted - 12/08/2012 :  02:28:54  Show Profile  Reply with Quote
thanks for your reply but it didn't returned any rows.

SELECT A.element_id,A.sample_timestamp,B.SYS_NAME,B.ALIAS, C.BITSIN,
A.CPUUTILIZATION,A.MemoryUTilization FROM
NHV_ST_B_104022 A JOIN NHV_ELEMENT_FOR_USER B
on A.element_id= b.element_id
JOIN NHV_ST_B_104050 C ON B.element_id = C.element_id

Ankita
Go to Top of Page

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 12/08/2012 :  08:30:25  Show Profile  Reply with Quote
In the example you posted, what is the output that you are expecting? You can change the joins to FULL JOIN and see if that meets your requirements:
SELECT * FROM 
A FULL JOIN B on A.id1 = b.id1
FULL JOIN C ON B.id1 = C.id1
If that is not it, please post sample input data long with the required output.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000