Is there a SQL construct or a trick to do something like:
SELECT i WHERE i BETWEEN 0 AND 10;
?
My first idea is to create a temporary table such as:
CREATE TABLE _range ( i INT PRIMARY KEY );
and fill it
INSERT INTO _range VALUES 0;
INSERT INTO _range VALUES 1;
etc.
Is there a better way?
UPDATE:
I use sqlite in this particular case but i am interested in general answer.
Very interesting question. Here’s an ugly hack that probably is useless unless your ranges are really that small…
Edit: Ok, so I got to thinking why not use cross joins. So, here is another hack and this one will quickly net you pretty large in memory tables and is perhaps reasonably good.
Will easily go to any power of 2 and should be fast enough.