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

Reply via email to