Previous Topic

Next Topic

SQL Clauses

SELECT clause

Retrieve data from tables, use to retrieve,

  • a single line, or part of a line, from a table, referred to as a singleton select.
  • multiple rows, or parts of rows, from a table.
  • Retrieve related rows, or parts of rows, from a join of two or more tables.

FROM clause

Specifies the tables that a SELECT statement retrieves data from.

JOIN clauses

Three types of JOIN clauses can be used in the FROM clause to perform relational joins between source tables. The implicit join condition is always Cartesian for source tables without an explicit JOIN clause. The following table outlines the three types of JOIN clauses that can be used in the FROM clause, or click the links for more detailed information about each type of join.

Type

Description

Cartesian

Joins two tables, matching each line of one table with each line from the other.

INNER

Joins two tables, filtering out non-matching rows.

OUTER

Joins two tables, retaining non-matching rows.

 

WHERE clause

The WHERE clause specifies filtering conditions for the SELECT statement.

GROUP BY clause

Combines rows with field values in common into single rows for the SELECT statement.

HAVING clause

Specifies filtering conditions for a SELECT statement.

ORDER BY clause

Sorts the rows retrieved by a SELECT statement.

FIRST clause

The query only returns the first N number of rows, respecting any GROUP BY, HAVING, or ORDER BY clauses.

UNION clause

Concatenates the rows of one table to the end of another table.

In This Section

SQL SELECT Clause

SQL FROM Clause

SQL JOIN Clauses

SQL WHERE Clause

SQL SELECTIVITY Clause

SQL GROUP BY Clause

SQL HAVING Clause

SQL ORDER BY Clause

SQL FIRST Clause

SQL UNION Clause

See Also

SQL Overview

Book Contents

Book Index