update temp_table set id=(select id from some_table where c=42), operation='UPDATE' where exists (select 1 from some_table s where s.a=temp_table.a and s.b=temp_table.b and s.c=42);
is the proper way of phrasing of a correlated subquery ... --- Theory is when you know everything but nothing works. Practice is when everything works but no one knows why. Sometimes theory and practice are combined: nothing works and no one knows why. >-----Original Message----- >From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users- >boun...@sqlite.org] On Behalf Of Luuk >Sent: Monday, 8 December, 2014 13:36 >To: sqlite-users@sqlite.org >Subject: Re: [sqlite] How do I update multiple rows in a single sql >statement > >On 8-12-2014 21:17, Igor Tandetnik wrote: >> On 12/8/2014 3:08 PM, Luuk wrote: >>> i hope this does it: >>> >>> update temp_table >>> set id=(select id from some_table where c=42), >>> operation='UPDATE' >>> where exists (select 1 >>> from some_table s, temp_table t >>> where s.a=t.a and s.b=t.b); >> >> This updates all rows in temp_table, as long as at least one row in >> temp_table matches one row in some_table. In other words, it updates no >> rows, or all rows - never just some. > >you are right.... > >update temp_table >set id=(select id from some_table where c=42), >operation='UPDATE' >where exists (select 1 > from some_table s, temp_table t > where s.a=t.a and s.b=t.b and s.c=42); >_______________________________________________ >sqlite-users mailing list >sqlite-users@sqlite.org >http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users