you canT specific target tablexx_themesFor update in from clause
1. Execute SQL as follows
UPDATE `xx_themes` SET `is_original` = (SELECT `is_original` FROM `xx_themes` WHERE `id` = '237') WHERE `id` = 248
2. Error: 1093 – you canT specific target tablexx_themesfor update in from clause. as shown in Figure 1
UPDATE `xx_themes` SET `is_original` = (SELECT `is_original` FROM `xx_themes` WHERE `id` = '237') WHERE `id` = 248
> 1093 - You can't specify target table 'xx_themes' for update in FROM clause
> 时间: 0s
3. Reference:https://dev.mysql.com/doc/refman/5.7/en/update.html, in MySQL, you cannot modify the same table used in the Select section. You can connect the table to itself, which will cause MySQL to treat the table as two different things, allowing for destructive changes. as shown in Figure 2
UPDATE `xx_themes` AS t
INNER JOIN `xx_themes` AS f ON t.id=248 and f.id=237
SET t.is_original = f.is_original

