hello again & thx 4 reply

i'll try with this. i am very new 2 sql and sqlite so i would like 2 find
the fastest way to do the operation i explained in the first post

thank you once more


Dennis Cote wrote:
> 
> 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
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Easy-question-concerning-C%2B%2B---sqlite3-tp15561319p15584651.html
Sent from the SQLite mailing list archive at Nabble.com.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to