JOIN Statements in SQL

An unbelievable amount of data is collected every day. This data is stored on computers, in a format of tables or grids, called a database. To access this information a system called Structured Query Language (SQL) was developed. These database structures can become huge an unwieldy if they are not "normalized". A normalized database is one in which the database has been split into compact tables, each with as few columns as is logically possible. The thing about normalization is that when information is accessed it is often needed from multiple tables at once. In order to smooth this process the SQL JOIN statement was developed.

The JOIN statement is used to combine two related tables, in a sense making a new temporary table from two permanent ones. By connecting data across tables the amount of duplication that must take place in the database is greatly reduced. There are many ways to JOIN, a standard JOIN is called an INNER JOIN. There is also an OUTER JOIN which is comprised of the LEFT JOIN, RIGHT JOIN, and FULL JOIN. JOINs generally rely on a PRIMARY KEY coupled with a FOREIGN KEY to effectively relate cross-table data. Because every cell in the PRIMARY KEY column is unique it can be referred to from another table. It allows us to call upon all the information in the referred to row without having to store it in the second table.

A related statement is the UNION, which does what the JOIN does, only it combines tables that have already been processed by a query (SELECTed) within a program.

For specific syntax, see each individual type of JOIN.


Send notes in disappearing ink!

Interesting Pages