If you have been using certain DBMSs, or reading recent versions
of the SQL standard, you are probably aware of the so-called
“WITH clause” of SQL.
Some call it Subquery Factoring. Others call
it Common Table Expression. A form of the WITH
CLAUSE, “WITH RECURSIVE”, allows to design a
recursive query: a query which repeats itself again and again,
each time using the results of the previous iteration. This can
be quite useful to produce reports based on hierarchical data.
And thus is an alternative to Oracle’s CONNECT BY. MySQL does not
natively support WITH RECURSIVE, but it is easy to emulate it
with a generic, reusable stored procedure. Read the full article
…
Showing entries 1 to 2
Dec
17
2013
Nov
18
2013
[2017 update: MySQL 8.0.1 now features SQL-standard CTE
syntax; more information is here ; the entry below, from 2013, shows how
to work around the absence of CTEs in older MySQL
versions.]
If you have been using certain DBMSs, or reading recent versions
of the SQL standard, you are probably aware of the so-called
"WITH clause" of SQL.
Some call it Subquery Factoring. Others call
it Common Table Expression (CTE). In its simplest
form, this feature is a kind of "boosted derived table".
Assume that a table T1 has three columns:
CREATE TABLE T1( YEAR …[Read more]
Showing entries 1 to 2