Select from same table as an Insert or Update

前端 未结 5 1757
走了就别回头了
走了就别回头了 2021-01-17 17:48

Clearly the following is incorrect.

INSERT INTO `aTable` (`A`,`B`) VALUES((SELECT MAX(`A`) FROM `aTable`)*2),\'name\');

I get the value:

5条回答
  •  臣服心动
    2021-01-17 18:38

    I think you need to drop the "VALUES", and have a valid select statement.

    see this link

    I'm not particularly a mySQL guy, I use MSSQL mostly. But If you format the select statement correctly, It should work.

提交回复
热议问题