SQLite Forum

select in order
Login
Using data that looks like this:

```
create table p (id integer primary key, other);
insert into p values (1, 'one'), (2, 'two'), (3, 'three'), (4, 'four');
```

You could use a query like this:

```
with ids (id) 
  as (
      values (3),
             (2),
             (4)
     ) 
     select p.* 
      from ids 
cross join p 
     where p.id == ids.id;
```

or like

```
  select p.*
    from (
          values (3),
                 (2),
                 (4)
         ) as ids
cross join p
     where p.id == ids.column1;
```

both of which only require you to build the values list once ...