Thanks Igor.  I assume your comment about the two queries not returning the
same results is because the LEFT JOIN query would return TableA rows with no
matching TableB rows, whereas the Scalar query would not.  How could I
change the scalar query to emulate the LEFT JOIN query?

Pete




------------------------------
>
> Message: 11
> Date: Wed, 29 Jun 2011 14:57:28 -0400
> From: Igor Tandetnik <itandet...@mvps.org>
> Subject: Re: [sqlite] Query Alternatives
> To: sqlite-users@sqlite.org
> Message-ID: <iufsld$o6h$1...@dough.gmane.org>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> On 6/29/2011 12:53 PM, Pete wrote:
> > Looking for opinions on the relative efiiciency of Scalar queries versus
> > non-scalar with JOIN statements.
> >
> > For example, the following two queries would produce the same results but
> > would one of them be significantly faster than the other?
> >
> > SELECT column1, tableB.column2 FROM TableA LEFT JOIN TableB ON
> > TablebB.indexcolumn = TableA.primarykeycolumn
> >
> > OR
> >
> > SELECT column1, (SELECT column2 FROM TableB WHERE TableB.indexcolumn =
> > TableA.primarykeycolumn) FROM TableA
>
> The two queries are not equivalent - the first one may return more rows.
> In those cases where they are equivalent, I strongly doubt you'll notice
> any performance difference.
> --
> Igor Tandetnik
>
>
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to