我的 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
我被难住了,有什么想法可以让我的计数再次增加吗?