问题
mysql环境执行以下语句:
“You can’t specify target table ‘mt_datasource’ for update in FROM clause”。
不能先select出同一表中的某些值,再update这个表(在同一语句中)1
2
3
4
5
6
7
8-- 更新数据库信息
UPDATE mt_datasource SET is_deleted = 0 where id IN
(
select id from mt_datasource where id in
(
select DISTINCT datasource_id from mt_table
)
)
处理方式
使用中间表规避
改写
1 | -- 更新数据库信息(逻辑删除) |