Showing relations

0 Saqlain Shah · August 4, 2015
How can we link two different tables ? how can we use foreign key?

Post a Reply

Replies

Oldest  Newest  Rating
0 mike richardson · August 5, 2015
NP!!!
0 Saqlain Shah · August 5, 2015
Thank you very much.It helped me alot.
0 mike richardson · August 4, 2015
When you create tables always create with a Primary Key. Then use that Key as a Foreign Key in another table you want to be able to join.

First Table - Users
UserID - PK
UserName

 Second Table - UserContact
UserContactID - PK
UserID - FK
Phone
Address
Email

Now when i want to use this i write my statement like so
SELECT usr.UserName, uc.Phone
FROM Users usr
INNER JOIN UserContact uc ON uc.UserID = usr.UserID
WHERE usr.UserID = 1
  • 1

SQL & Databases

106,957 followers
About

Everything SQL and Databases related in here!

Links
Moderators
Bucky Roberts Administrator