【发布时间】:2018-12-26 17:42:11
【问题描述】:
我目前有一条 SQL 语句:
UPDATE table_1 SET
property_1=b.value_1,
property_2=b.value_2,
property_3=b.value_3
FROM (
SELECT a.property_4, a.property_5, b.value_2, b.value_3
FROM (
SELECT id1 AS property_4, MAX(id2) AS property_5
FROM table_2
WHERE
id1 IN (...) AND
id2 NOT IN (...)
) a
JOIN table_3 b ON
a.property_5 = b.id
) a
WHERE
table_1.id = a.property_4
这在我们的生产 postgresql db 上运行良好,但是 UPDATE 的语法在 SQLite 中是不同的(我们在测试中使用的),我发现我自己对如何转换它很困惑。我收到的错误是Error: syntax error near FROM。如果有人是 SQLite 高手,我将不胜感激。
【问题讨论】:
标签: sql postgresql sqlite