question

SQLShelly avatar image
SQLShelly asked

SQL - 2 tables not connected, 1 commond ID.....

I have two tables that are not connected, but they have one common ID. I want to be able to connect them and show different values from both tables based on the results. sorry and a join will not work because they don't have a FK or PK relationship.
sql
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
ThomasRushton avatar image
ThomasRushton answered
So you're looking to [JOIN][1] the tables ON that common ID, and [SELECT][2] data from those tables... SELECT < > FROM < > A JOIN < > B ON A.ID = B.ID WHERE < > [1]: http://msdn.microsoft.com/en-us/library/ms191517.aspx [2]: http://msdn.microsoft.com/en-us/library/ms190617.aspx
3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ThomasRushton avatar image ThomasRushton ♦♦ commented ·
They don't have to have an explicitly defined FK/PK relationship for you to create a JOIN. It's a common use, but it's not required.
2 Likes 2 ·
Blackhawk-17 avatar image Blackhawk-17 commented ·
THE FK and PK are there to manage data integrity, not logical relationships per se.
1 Like 1 ·
SQLShelly avatar image SQLShelly commented ·
But the tables are not related so a join won't work because they don't have a FK or PK relationship.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.