2012-02-10 62 views
1

我有以下SQL查詢:MySQL的 - 更新的目標表是不可更新

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; 

當我運行它,我得到以下錯誤信息:

The target table TBL_1 of the UPDATE is not updatable. 

我需要更新table_B中批次值爲10的table_B中的列'b_name'。

任何幫助最受讚賞。

+0

'SELECT * FROM表-A ...'什麼ü得到 – mgraph 2012-02-10 13:51:36

+0

乍一看,你不應該說「SET table_B.b_name =‘測試’」? – 2012-02-10 13:55:12

回答

1
update table_B b 
set b.b_name = 'test' 
where b.a_fk in 
(
select id from table_A where batch=10 
) 
當您運行只有這部分