Recursive Common Table Expressions Overview
You are viewing an old version of this article. View
the current version here.
Common Table Expressions (CTEs) are a standard SQL feature, and are essentially temporary named result sets.
There are two kinds of CTEs:
- Non-recursive
- Recursive, which this article covers.
SQL is generally poor at recursive structures.
Oracle first attempted something similar in the 1980's with the CONNECT BY syntax. They appeared in the SQL standard in 1999, and the first implementations began appearing in 2007.
Syntax
Computation
Given the following structure:
First execute the anchor part of the query:
Next, execute the recursive part of the query:
Comments
Comments loading...
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.