SQLite Forum

Reference to RECURSIVE table column apparently not allowed in nested SELECT
Login
The following statement works as expected

```
WITH RECURSIVE
  cnt ( x , list , done , Pagelist ) AS (
    VALUES ( 1 , 1 , 0 , '' ) UNION ALL
    SELECT x + 1 AS x ,
    ( list || ',' || ( cnt.x + 1 ) ) AS list,
    ( x == 9 ) AS done ,
    ( SELECT Page FROM GetreuerMusicMeister LIMIT 1 ) AS Pagelist
    FROM cnt WHERE x < 10
  )
SELECT list , Pagelist FROM cnt WHERE done == 1 ;
```
and produces a single row with fields '1,2,3,4,5,6,7,8,9,10' and a null (which happens to be the Page field of the first record of GetreuerMusicMeister). The following statement
```
WITH RECURSIVE
  cnt ( x , list , done , Pagelist ) AS (
    VALUES ( 1 , 1 , 0 , '' ) UNION ALL
    SELECT x + 1 AS x ,
    ( list || ',' || ( cnt.x + 1 ) ) AS list,
    ( x == 9 ) AS done ,
    ( SELECT Page FROM GetreuerMusicMeister LIMIT cnt.x ) AS Pagelist
    FROM cnt WHERE x < 10
  )
SELECT list , Pagelist FROM cnt WHERE done == 1 ;
```
fails with the error
no such column: cnt.x Unable to execute statement

It looks as if the table "cnt" is somehow no longer visible inside the nested SELECT statement used as an expression.