You can't specify target table for update in FROM clause

前端 未结 11 1374
野趣味
野趣味 2020-11-21 22:46

I have a simple mysql table:

CREATE TABLE IF NOT EXISTS `pers` (
  `persID` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(35) NOT NULL,
  `gehalt` int(11         


        
11条回答
  •  忘掉有多难
    2020-11-21 23:22

    In Mysql, you can not update one table by subquery the same table.

    You can separate the query in two parts, or do

     UPDATE TABLE_A AS A
     INNER JOIN TABLE_A AS B ON A.field1 = B.field1
     SET field2 = ? 

提交回复
热议问题