0

我在下面的查询中运行了这个,它给出了错误:

UPDATE t_o
SET t_o.mlm_order_id = mt.order_id 
FROM temp_orders t_o, mlm_transaction mt
WHERE mt.v2_order_id = t_o.order_id

错误是:

#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 temp_orders t_o, mlm_transaction mt WHERE mt.v2_order_id = t_o.order_id' 
at line 3

请帮忙 ??

4

4 回答 4

1

One more version -

UPDATE temp_orders t_o, mlm_transaction mt
SET t_o.mlm_order_id = mt.order_id 
WHERE mt.v2_order_id = t_o.order_id
于 2012-10-30T06:39:43.033 回答
1

您正在使用的是 . 的语法SQLServer。这相当于MySQL

UPDATE temp_orders t_o 
       INNER JOIN mlm_transaction mt
            ON mt.v2_order_id = t_o.order_id
SET    t_o.mlm_order_id = mt.order_id 
于 2012-10-30T06:27:33.710 回答
0

Updates don't use the FROM clause.

Use something like this:

UPDATE table_name SET column1=value1, column2=value2,... WHERE some_column=some_value
于 2012-10-30T06:40:15.280 回答
0

你可以试试这个,但未经测试:

UPDATE t_o
SET t_o.mlm_order_id = mt.order_id 
WHERE t_o.mlm_order_id = (SELECT mt.v2_order_id FROM mlm_transaction mt WHERE mt.v2_order_id = t_o.order_id)
于 2012-10-30T06:27:43.197 回答