2

我找到了我搜索的 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 不支持内连接

4

1 回答 1

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')
于 2012-09-01T20:48:34.220 回答