SQlite增量字段并不存在

时间:2013-01-26 10:35:06

标签: sqlite

我的SQLite代码可以使用它,递增计数,并将foo添加到我的数据库中:

INSERT or REPLACE into masterWords  (words, count) 
values ("foo", coalesce ((select count + 1 
from masterWords where  words = "foo" ), 1))

但是当我添加NOT EXISTS时,不再计数增量。

INSERT or REPLACE into masterWords  (words, count) 
values ("foo", coalesce ((select count + 1 
from masterWords where  words = "foo" ), 1)  
AND  NOT EXISTS ( SELECT DISTINCT mWord 
from mWords where mWords.mWord = "foo" ))

表:masterWords包含列字,count table:mWords包含mWord列

我很难过,有什么想法让我的计数再次增加?

1 个答案:

答案 0 :(得分:0)

INSERT or REPLACE into masterWords  (words, count) 
values ("foo", coalesce ((select count + 1 
from masterWords where  words = "foo" ), 1  
AND  NOT EXISTS ( SELECT DISTINCT mWord 
from mWords where mWords.mWord = "foo" )))

只需要移动支架。只要没有异议,我就会把问题和解决方案留给某人使用。