Both of the answers here are pretty good if you have a primary key/unique constraint on the name
https://stackoverflow.com/questions/3647454/increment-counter-or-insert-row-in-one-statement-in-sqlite My personal favourite is there as: BEGIN; INSERT OR IGNORE INTO observations VALUES (:src, :dest, :verb, 0); UPDATE observations SET occurrences = occurrences + 1 WHERE src = :src AND dest = :dest AND verb = :verb; COMMIT; On 20 Mar 2015, at 11:07, Felipe Gasper <felipe at felipegasper.com> wrote: > Hello, > > I?m looking for logic like this: > > INSERT data > ON CONFLICT oldrow.col1 += oldrow.col2 > > Does SQLite have anything that would make this simpler than: > > 1) UPDATE > 2) if 0 rows updated, then INSERT > > Thank you! > > ?? > > -FG > _______________________________________________ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: Message signed with OpenPGP using GPGMail URL: <http://mailinglists.sqlite.org/cgi-bin/mailman/private/sqlite-users/attachments/20150320/b6070fbb/attachment.pgp>

