Thursday 13 June 2013

Unit 4 - JOIN (Obtaining Data From More than One Table)

An SQL JOIN clause is used to combine rows from two or more tables, based on a common field between them.
Sometimes we need to use data from more than one table. Rows in one table can be joined to rows in another table according to common values; i.e. usually primary and foreign key columns.

Types of Joins

Joins (8i and Prior)                           SQL:1999 (Complaint Joins)

Cartesian Products:

A Cartesian Product is formed when:
  •       A join condition is omitted.
  •      A join condition is invalid.
  •      All rows in the  first table are joined to all rows  in the second table.

To avoid a Cartesian product, always have a valid join condition in a WHERE clause.

Example:




No comments:

Post a Comment