SQLite (SQLiteStudio 3.3.3): select from hardcoded list of values

387 Views Asked by At

I need to select few constants as if it was a table. I found similar question for postgress:

Select hardcoded values without table

But it doesnt work with SQLite. This:

select * from (
  values (1),(2),(3),(4),(5)
);

returns 1 5 times instead.

How do I fix it?

enter image description here

1

There are 1 best solutions below

4
Boppity Bop On

It seems to be a bug. According to this it worked in previous version of sqlite: How do I name the output column in a sqlite values clause?

However this works as expected:

with cte(a) as (values (1),(2),(3),(4),(5))
  select * from cte;