尝试从sqlite数据库更新数据时,SQL错误或缺少数据库(在"。":语法错误)错误

时间:2017-12-24 13:57:47

标签: java sql sqlite

我一直在java中遇到这个错误。我确实看过类似的问题,但他们没有帮助。有人能解决吗?感谢

UPDATE SearchedWords 
SET SearchedWords.NrOfSearches=SearchedWords.NrOfSearches+1 
FROM SearchedWords
INNER JOIN Dictionary ON SearchedWords.WordID=Dictionary.ID 
WHERE Dictionary.Word=? AND SearchedWords.UserID=?;

1 个答案:

答案 0 :(得分:2)

SQLite不支持JOIN中的UPDATE。这是一个解决方法:

UPDATE SearchedWords 
    SET NrOfSearches = NrOfSearches + 1 
    WHERE EXISTS (SELECT 1
                  FROM Dictionary d
                  WHERE d.ID = SearchedWords.WordID AND
                        d.Word = ?
                 ) AND
          UserID = ?;