On Fri, Dec 18, 2009 at 8:23 PM, Valerio Aimale <vale...@aimale.com> wrote:
> Hello all,
>
> I've run into an interesting situation; when duplicating parenthesis
> around a 'in ()' subquery, only the first row is returned.
>
> This is not my real-life query, but a test that replicates the problem.
>
> Thanks,
>
> Valerio
>
> $ sqlite3 --version
> 3.6.16
>
> prepare some dummy data:
>
> create table test ( id INT );
> insert into test VALUES(1);
> insert into test VALUES(2);
> insert into test VALUES(3);
> insert into test VALUES(4);
> insert into test VALUES(5);
> insert into test VALUES(6);
> insert into test VALUES(7);
> insert into test VALUES(8);
> insert into test VALUES(9);
> insert into test VALUES(10);
>
> sqlite> select id from test where (id > 5);
> 6
> 7
> 8
> 9
> 10
> [Good]
>
> sqlite> select id from test where id in (select id from test where (id >
> 5));
> 6
> 7
> 8
> 9
> 10
> [Still Good]
>
> Now let's duplicate parenthesis around the subquery:
>
> sqlite> select id from test where id in ((select id from test where (id
>  > 5)));
> 6
>
> Why only one value returned when parenthesis are duplicated?
>
> Same with triple parenthesis enclosing:
>
> sqlite> select id from test where id in (((select id from test where (id
>  > 5))));
> 6
>


Given the above table

sqlite> SELECT id FROM test WHERE id IN (6, 7, 8, 9, 10);
id
----------
6
7
8
9
10
sqlite> SELECT id FROM test WHERE id IN ((6, 7, 8, 9, 10));
SQL error: near ",": syntax error
sqlite>

Seems like IN expects a comma separated list, and nothing else within
a single set of parens.




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

Reply via email to