> Are you sure that was the OP's intention? No, I'm not sure, of course, because OP didn't answer yet. But words "First row with id 3" and "Third row with id 3" suggested to me that they are different rows. And mentioning SQLITE_CONSTRAINT I've interpreted as "unique constraint on id-count pair". So let's wait for the answer. :)
Pavel On Wed, Aug 19, 2009 at 12:05 PM, Igor Tandetnik<[email protected]> wrote: > Pavel Ivanov <[email protected]> wrote: >>> insert or replace into mytable(id, count) >>> values (:id, coalesce((select count from mytable where id=:id), 0) + >>> 1); >> >> I guess it doesn't work as OP intended: >> >> sqlite> select * from t; >> id|count >> 1|1 >> 1|2 >> 1|3 >> 1|4 > > Are you sure that was the OP's intention? His pseudocode suggests to me > that id is supposed to be unique, and the count should reflect how many > times this particular id was inserted. He definitely mentions > SQLITE_CONSTRAINT, while your table doesn't appear to be constrained in > any way. > > Igor Tandetnik > > > > _______________________________________________ > sqlite-users mailing list > [email protected] > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

