andrew fabbro wrote: > What is the most efficient way to code either a trigger or the app so > that it increments a "count" field if the "id" field exists? > > For example, say you have a table with fields of "id" and "count". > > First row is an id of 3, so "count" is set to 1. > Next row is an id of 4, so "count" is set to 1. > Third row is an id of 3 again, so "count" is incremented to 2.
insert or replace into mytable(id, count) values (:id, coalesce((select count from mytable where id=:id), 0) + 1); Igor Tandetnik _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

