I know this won't work. I tried it in various forms and failed all times. What is the simplest way to achieve the following result?
ALTER TABLE XYZ AUTO_INCREMENT = (select max(ID) from ABC);
This is great for automation projects.
SELECT @max := (max(ID)+1) from ABC; -> This works!
select ID from ABC where ID = (@max-1); -> This works!
ALTER TABLE XYZ AUTO_INCREMENT = (@max+1); -> This fails :( Why?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…