Alexander Batyrshin <[EMAIL PROTECTED]>
wrote:
> Hello All,
> For example we have table like this:
>
> CREATE TABLE map (
>  name text,
>  x integer,
>  y integer
> );
> CREATE INDEX map_xy ON map(x,y);
>
> How to query this table with "IN" keyword?
> Query like this, doesn't work:
>
> SELECT * FROM map WHERE (x,y) IN ((1,1),(1,2),(1,3));

IN only works on a single column. The closest you can get to this is 
something like

SELECT map.*
FROM map join (
     select 1 x, 1 y
     union all
     select 1 x, 2 y
     union all
     select 1 x, 3 y) t
ON map.x = t.x AND map.y=t.y;

I checked - it does use map_xy index. The subselect in parentheses 
essentially creates a temporary table, which is then joined with your 
main table.

Igor Tandetnik



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to