On Wed, Feb 20, 2013 at 7:17 AM, Marcin Kałuża <marcin.kal...@megiteam.pl>wrote:

> We've encountered strange sqlite behavior:
>
> SQLite version 3.7.15.2 2013-01-09 11:53:05
> Enter ".help" for instructions
> Enter SQL statements terminated with a ";"
> sqlite> create table t(v int4);
> sqlite> insert into t values (1),(2),(3);
> sqlite> select * from t where v = (select v from t);
> 1
> sqlite> select * from t where v in (select v from t);
> v
> ----------
> 1
> 2
> 3
>
> While on postgres it works like this (as far as I remember oracle does
> this as well, and that's the way it should work imho):
> mail=> create table t (v int4);
> CREATE TABLE
> mail=> insert into t values (1),(2),(3);
> INSERT 0 3
> mail=> select * from t where v = (select v from t);
> ERROR:  more than one row returned by a subquery used as an expression
> mail=> select * from t where v in (select v from t);
>  v
> ---
>  1
>  2
>  3
> (3 rows)
>
> Is this a bug, or a feature?
>

SQLite automatically adds a LIMIT 1 to a scalar subquery.



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

Reply via email to