我有一个自动递增的列 ID,在某些情况下我希望其他列等于主键 + 1 个值
ID | other
1 | 2
2 | 3
3 | 4
4 | 123 (some situation, it is not always plus 1)
我怎样才能做到这一点?
这是我尝试过的
INSERT INTO table (`ID`,`other`) VALUES ('',(SELECT MAX(ID)+1 FROM table))
但是返回错误
You can't specify target table 'table' for update in FROM clause
最佳答案
尝试下面的查询:
ALTER TABLE dbo.table ADD
Column AS ([ID]+1)
GO
肯定有用
关于mysql插入值等于主键+ 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17874613/