我发现我搜索过的SQL更新了一些字段,但我收到了标题的错误:
UPDATE a
SET a.json = 'ex', a.last_save = 'ex', a.carte = 'ex'
FROM partie_l AS a
INNER JOIN carte AS b
ON a.start_carte = b.hash
WHERE b.json = 'ex' AND a.start_joueurs = 'ex' AND a.param = 'ex'
我用ex替换了我的数据,否则它会太长。
这是我桌子的结构。
CREATE TABLE "carte" ("hash" TEXT NOT NULL PRIMARY KEY ,"json" TEXT NOT NULL ,"nb_jrs" INTEGER,"preview" BLOB, "creator" TEXT DEFAULT atoll, "name" TEXT, "tetra" BOOL)
CREATE TABLE "partie_l" ("id" INTEGER PRIMARY KEY NOT NULL ,"json" TEXT,"create" DATETIME,"last_save" DATETIME,"start_carte" TEXT,"preview" BLOB,"param" TEXT,"start_joueurs" TEXT,"carte" TEXT, "name" TEXT)
编辑:Sqlite不支持内连接
答案 0 :(得分:1)
尽量不要使用表别名来更新表。
UPDATE partie_l
SET json = 'ex',
last_save = 'ex',
carte = 'ex'
FROM partie_l
INNER JOIN carte AS b
ON partie_l.start_carte = b.hash
WHERE b.json = 'ex' AND partie_l.start_joueurs = 'ex' AND partie_l.param = 'ex'
对于SQLite,请尝试
UPDATE partie_l
SET json = 'ex',
last_save = 'ex',
carte = 'ex'
WHERE partie_l.start_joueurs = 'ex'
AND partie_l.param = 'ex'
AND partie_l.start_carte IN (SELECT hash FROM carte WHERE json='ex')