Oh you’re right. I realize now I messed up the example. Here are the updated queries:
Query A SELECT * FROM tab1 LEFT JOIN tab2 ON tab2.x='constant' WHERE tab1.x='constant’; Query B SELECT * FROM tab1 LEFT JOIN tab2 ON tab1.x=tab2.x WHERE tab1.x=‘constant These return the same results in your sample setup. I think Simon pointed out what I’m also thinking is the problem: could Query A return rows that aren’t matched up properly because of a lack of a constraint joining the 2 tables? Thanks for putting together that more complete example :). Ben > On Oct 27, 2019, at 3:35 PM, Richard Hipp <d...@sqlite.org> wrote: > > On 10/27/19, Benjamin Asher <benashe...@gmail.com> wrote: >> It seems both of the following work, >> but I’m not really sure why: > > I get different answers for the two queries when I try them: > > CREATE TABLE tab1(x,y); > CREATE TABLE tab2(x,y); > INSERT INTO tab1 VALUES('constant','string'),('abc','def'),(97,15); > INSERT INTO tab2 SELECT * FROM tab1; > > SELECT * FROM tab1 LEFT JOIN tab2 ON tab1.x='constant'; > > SELECT * FROM tab1 LEFT JOIN tab2 ON tab1.x=tab2.x WHERE tab1.x='constant'; > > > -- > D. Richard Hipp > d...@sqlite.org > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users