具有 2 个内部连接的 SQLite Delete 语句
SQLite Delete statement with 2 inner joins
为什么我会收到此语句的错误?
Error: could not prepare statement (1 near "t3": syntax error)
(注意:为简单起见重命名表格)
DELETE FROM table3 t3
INNER JOIN table2 t2 ON t2.tempId = t3.tempId
INNER JOIN table1 t1 ON t1.tempId = t2.tempId
WHERE t1.tempId = 9;
"Heh ..." 我不认为 DELETE
语句知道 任何 关于 "joins" ...
...我确实认为我理解*为什么(不)。"
相反,这样做:
- 开始交易。
- 运行
SELECT
查询以获取满足您的记录 ID 列表
选择标准。
- "Aww, heck ..." 继续将这些记录 ID 的列表转储到某处的某个日志文件中....
- 执行一系列
DELETE
查询以删除这些 ID。
COMMIT
。 (或者,如果出现任何问题,ROLLBACK
。)
为什么我会收到此语句的错误?
Error: could not prepare statement (1 near "t3": syntax error)
(注意:为简单起见重命名表格)
DELETE FROM table3 t3
INNER JOIN table2 t2 ON t2.tempId = t3.tempId
INNER JOIN table1 t1 ON t1.tempId = t2.tempId
WHERE t1.tempId = 9;
"Heh ..." 我不认为 DELETE
语句知道 任何 关于 "joins" ...
...我确实认为我理解*为什么(不)。"
相反,这样做:
- 开始交易。
- 运行
SELECT
查询以获取满足您的记录 ID 列表 选择标准。 - "Aww, heck ..." 继续将这些记录 ID 的列表转储到某处的某个日志文件中....
- 执行一系列
DELETE
查询以删除这些 ID。 COMMIT
。 (或者,如果出现任何问题,ROLLBACK
。)