How do you convert IBM DB2's recursive increment to MySQL version?
Question
DB2 Queries:
WITH
TABLE1 (YEAR_END) as( VALUES
(2011))
,
TABLE2
(YEAR_END) AS ( VALUES(2011))
,
TABLE3 (YEARS) AS ( SELECT 0+2008 FROM TABLE1 T1, TABLE2 T2
union all
select YEARS+1 from TABLE1 T1, TABLE2 T2, TABLE3 T3
WHERE YEARS < 2011
)
select YEARS from TABLE3
Result:
2008 2009 2010 2011
how to change above DB2 statement to Mysql statement?
Solution
Recursive SQL Constructs of this nature do not exist in MySQL.
I know something like ths can be done in SQL Server 2005.
The only WITH operator in MySQL is the WITH ROLLUP modifier clause in GROUP BY functions.
Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange