On Tue, 24 Sep 2013 20:21:09 +0200 Petite Abeille <petite.abei...@gmail.com> wrote:
> On Sep 24, 2013, at 8:05 PM, Simon Slavin <slav...@bigfraud.org> > wrote: > > > Which is why you do an INSERT first, and allow it to fail, then do > > the UPDATE. > > Sure. A lot of error proce procedural code to do what one SQL > statement could do much more naturally. Which is why you should update T where exists (select 1 from source ...) insert into T ... select ... where not exists [in T] Because this question comes up quite often, I added a discussion about it to my canonical sql page at http://www.schemamania.org/sql/#some.rows. No procedural code, no forced errors, and no dodgy semantics. Test rows affected if you want to skip the insert in the cases where all rows are updated. --jkl _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users