本文介绍了mysql - UPDATE 的目标表不可更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下 sql 查询:

I have the following sql query:

UPDATE
(SELECT * FROM table_A INNER JOIN table_B
ON table_A.id=table_B.a_fk
WHERE table_A.batch=10) AS TBL_1
SET TBL_1.b_name = "test" WHERE TBL_1.a_fk = 67532;

当我运行它时,我收到以下错误消息:

When i run it, i get the following error message:

The target table TBL_1 of the UPDATE is not updatable.

我需要更新 table_B 中的列 'b_name',其中 table_A 中的批处理值为 10.

I need to update the column 'b_name' in table_B where the batch value is 10 in table_A.

非常感谢任何帮助.

推荐答案

update table_B b
set b.b_name = 'test'
where b.a_fk in
(
select id from table_A where batch=10
)

这篇关于mysql - UPDATE 的目标表不可更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 09:00
查看更多