我正在尝试更新 MySql 中的 2 个不同的表,同时我将它们都内部连接在一起。
这是我最后一次尝试返回以下错误
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM ticketing_system_issues AS i INNER JOIN ( SELECT d.notes, d.issue' at line 8
UPDATE i, dis
SET i.category_id = 5,
i.priority = 1,
i.issue_title = "This is a test",
dis.notes = "This is a notes test",
i.modified_on = NOW(),
i.modified_by = 2
FROM ticketing_system_issues AS i
INNER JOIN (
SELECT d.notes, d.issue_id FROM ticketing_system_discussions AS d
INNER JOIN (
SELECT issue_id, MIN(created_on) AS min_time FROM ticketing_system_discussions
GROUP BY issue_id
) AS sub ON sub.issue_id = d.issue_id AND d.created_on = sub.min_time
) AS dis ON i.issue_id = dis.issue_id
WHERE i.issue_id = 58
如需更多测试以下查询以查找我喜欢更新的字段
SELECT i.category_id, i.priority, i.issue_title, dis.notes, i.modified_on, i.modified_by
FROM ticketing_system_issues AS i
INNER JOIN (
SELECT d.notes, d.issue_id FROM ticketing_system_discussions AS d
INNER JOIN (
SELECT issue_id, MIN(created_on) AS min_time FROM ticketing_system_discussions
GROUP BY issue_id
) AS sub ON sub.issue_id = d.issue_id AND d.created_on = sub.min_time
) AS dis ON i.issue_id = dis.issue_id
WHERE i.issue_id = 58