Receive all updates via Facebook. Just Click the Like Button Below

Blogger Widgets
/

Watch Intro About My Website ! ! !

Sunday, 3 November 2013


SQL joins are used to query data from two or more tables, based on a relationship between certain columns in these tables.

The JOIN keyword is used in an SQL statement to query data from two or more tables, based on a relationship between certain columns in these tables.

Tables in a database are often related to each other with keys.
A primary key is a column (or a combination of columns) with a unique value for each row. Each primary key value must be unique within the table. 

The purpose is to bind data together, across tables, without repeating all of the data in every table.

Look at the "Persons" table:

Id
LastName
FirstName
Address
City
1
Navis
Anto
Madras
TVL
2
Ji
Bala
Bombay
TVL
3
Christopher
Franklin
America
KK

Note: that the "Id" column is the primary key in the "Persons" table. This means that no two rows can have the same Id.

The Id distinguishes two persons even if they have the same name.

Next, we have the "Orders" table:

Id
OrderNo
Id
1
77895
3
2
44678
3
3
22456
1
4
24562
1
5
34764
15

Note that the "Id" column is the primary key in the "Orders" table and that the "Id" column refers to the persons in the "Persons" table without using their names.

Notice that the relationship between the two tables above is the "Id" column.


Tagged:

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...