Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.