문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 dba.stackexchange
scroll top