January 26th, 2009

Introduction to JOINs

Posted by admin in L. JOINs

All of the queries up to this point have retrieved rows from a single table, but using a relational database means retrieving relational data from multiple tables.A JOIN is a table operation that uses related columns to combine rows from two or more input tables into one result table.

This is where the relational database (RDBMS) has its true power. There is so much more information that can be obtained from tables, through joins of related data, using the SELECT statement.

Most join statements can be rewritten as subselects and most subselect statements can be rewritten as joins.> Table columns used to join two or more tables do not have to be SELECTed, they just have to be in the JOIN or WHERE clause. However, these columns may appear in the SELECT statement if you wish to see them in the results table.

> Access, DB2, and SQL Server do not support NATURAL JOIN syntax. See NATURAL JOIN.

> MySQL only supports a NATURAL JOIN on an OUTER JOIN, not an INNER JOIN. It also uses the non-standard STRAIGHT_JOIN. See INNER JOIN and OUTER JOIN.

> Oracle 8i and earlier does not support the JOIN syntax. Only Oracle 9i and beyond support the JOIN syntax.
If JOIN is not supported, use the WHERE clause.

> PostgreSQL supports all JOINs.

Comments are closed.

Sorry, the comment form is closed at this time.