First page Back Continue Last page Overview Graphics


Notes:

For a few years, most of the commercial SQL databases have supported recursive queries using the WITH clause, referred to as common table expressions.

Recently, a couple open source databases, Firebird and PostgreSQL, have added support for these clauses.

A recursive query works using a UNION statement. The first part of the UNION statement is a nonrecursive base clause. The second part is the recursive clause.

The query recursively queries it's own output until no rows are returned. Recursive queries are commonly used to return all descendents in a tree structure, which is otherwise impossible in standard SQL.