SQLite Forum

Reference to RECURSIVE table column apparently not allowed in nested SELECT
Login
Well, if "The recursive table" includes references to columns in it, then this rule is broken in the first example given in section 3.1
```
WITH RECURSIVE
  cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<1000000)
SELECT x FROM cnt;
```
where "x" appears twice *outside* the FROM clause

If I remove the "cnt." from my example
```
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 x ) AS Pagelist
    FROM cnt WHERE x < 10
  )
SELECT list , Pagelist FROM cnt WHERE done == 1 ;
```
it still doesn't work, but the error message refers to "x" rather than "cnt.x".

So the rule seems to be applied more strictly in subqueries.