1

我的 SQLite 代码适用于此,增加我的计数,并将 foo 添加到我的数据库中:

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

但是当我添加不存在时,计数不再增加。

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 表:mWords 包含列 mWord

我被难住了,有什么想法可以让我的计数再次增加吗?

4

1 回答 1

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" )))

只需要一个移动支架。只要没有异议,我认为我会将问题和解决方案留给某人可能有用。

于 2013-01-26T10:41:36.333 回答