更新内部联接问题

时间:2012-11-21 06:24:56

标签: mysql sql

我不知道我的查询有什么问题,但是我收到了这个错误:

Error Code : 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 a
INNER JOIN table2 b
ON  a.column1 = b.column1 AND a.column2 = b.column2' at line 4

这是我正在尝试的SQL:

UPDATE table1 AS a
Set a.Closed = 2

From a
INNER JOIN table2 b
ON  a.column1 = b.column1 AND a.column2 = b.column2
WHERE number in (01809076,02170039);

3 个答案:

答案 0 :(得分:5)

MySQL中的

UPDATE加入的语法是这样的。 (没有FROM条款

UPDATE  table1 AS a
        INNER JOIN table2 b
            ON  a.column1 = b.column1 AND 
                a.column2 = b.column2
SET     a.Closed = 2
WHERE   b.number in (01809076,02170039);

您当前使用的是T-SQL

答案 1 :(得分:0)

请更新您的查询:

更新table1 设置已关闭= 2

来自table1 a INNER JOIN table2 b ON a.column1 = b.column1 AND a.column2 = b.column2 中的数字(01809076,02170039);

一定会有效

由于 UTTAM

答案 2 :(得分:0)

您可以轻松完成:

UPDATE  table1,table2 
SET     table1.Closed = 2
WHERE   table1.column1 = b.column1 AND table1.column2 = table2.column2 AND table2.number in (01809076,02170039) ;