我如何才能完成这项工作 - 给我#1093 - 您无法在FROM子句中为更新指定目标表'Orders'
Update Orders set flag = 0 where orders_id = (select orders_id from orders ORDER BY orders_id DESC LIMIT 1)
答案 0 :(得分:1)
您需要将其包装在子查询中(创建临时表)
Update Orders
set flag = 0
where orders_id =
(
SELECT x.orders_id
FROM
(
select orders_id
from orders
ORDER BY orders_id DESC
LIMIT 1
) x
)
或
Update Orders
set flag = 0
where orders_id =
(
SELECT x.orders_id
FROM
(
select MAX(orders_id) orders_id
from orders
) x
)
答案 1 :(得分:0)
看起来你正在尝试更新表格中的最后一个订单?尝试
Update Orders set flag = 0 ORDER BY orders_id DESC LIMIT 1;
Mysql不支持在子查询中使用它时更新表。