vl.pavlov wrote:
>
> C++ aplication should put words into sqlite3 database, but if word that
> should be put into the dbase is already in the table of the dbase it should
> increase the number which is in the second column of the same row. how?
>
> eg:
> coffee | 3
> milk | 1
>
> ...
>
> i use standard functions from sqlite3.h
>
You can try this:
create table words (word text primary key, count integer);
insert or replace into words values(:word,
coalesce((select count from words where word = :word) + 1, 1));
It will replace the row with a new one that has the count incremented if
the word already exists. It will insert the word with a count of 1 if not.
HTH
Dennis Cote
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users