SQLite Forum

Docs / Simple SELECT statement (formed via VALUES) and WITH clause
Login

Docs / Simple SELECT statement (formed via VALUES) and WITH clause

(1.3) By Dmitrii Vitenberg (vitenbergd) on 2021-03-05 06:39:42 edited from 1.2 [source]

Hello, everyone!

Documentation page about SELECT statement in the overview section of select-stmt says that:

Note that there are paths through the syntax diagrams that are not allowed in practice. Some examples: A VALUES clause can be the first element in a compound SELECT that uses a WITH clause, but a simple SELECT that consists of just a VALUES clause cannot be preceded by a WITH clause.

But i didn't quite get the last case:

but a simple SELECT that consists of just a VALUES clause cannot be preceded by a WITH clause

Should it be a syntax error? Or this statement (WITH + VALUES) just makes no sense? I've tried to reproduce:

sqlite> WITH t(c) AS (SELECT 5) VALUES((SELECT * FROM t),2,3);
5|2|3

sqlite3 version:

~$ sqlite3 -version
3.31.1 2020-01-27 19:55:54 3bfa9cc97da10598521b342961df8f5f68c7388fa117345eeb516eaa837balt1
Seems like it's possible to form that kind of statement. Can someone please help me to clarify ?

Thanks in advance.