simonw / til

Today I Learned
https://til.simonwillison.net
Apache License 2.0
1.02k stars 81 forks source link

minor issue on simple-recursive-cte.md? #43

Closed bucweat closed 2 years ago

bucweat commented 2 years ago

Was reading https://github.com/simonw/til/blob/main/sqlite/simple-recursive-cte.md and wondering if the last query on the page

with recursive counter(x, y) as (
  select 0 as x, 1 as y
    union
  select x + 1, x + 2 from counter
)
select * from counter limit 5;

should read

with recursive counter(x, y) as (
  select 0 as x, 1 as y
    union
  select x + 1, y + 2 from counter
)
select * from counter limit 5;

Note replacement of x+2 with y+2. That would result in the following (from my own VBScript tool using ODBC) which seems to be your intention:

x(vbLong):0,y(vbLong):1
x(vbLong):1,y(vbLong):3
x(vbLong):2,y(vbLong):5
x(vbLong):3,y(vbLong):7
x(vbLong):4,y(vbLong):9

Yeah I know you're asking why not use Datasette...I'd love to but I'm limited to what is provided by OS and what can be compiled with Visual Studio. So for scripting it is VBScript/Javascript and ADO recordsets via ODBC. But I do read/love your site/blog/TIL and always try to keep up with posts just for the SQLite tidbits :-)

simonw commented 2 years ago

Yea it should, thanks!