How to set Auto_Increment value based on a variable? Is it possible to set the auto-increment value in MySQL based on a variable?

SELECT 1 + MAX(id) 
INTO @newAiValue
FROM Result_Import_Archive;

ALTER TABLE Result_Import
AUTO_INCREMENT = @newAiValue;


This is what I intend to do, however, MySQL complains that it is syntactically incorrect.
You can do it with a prepared statement.

set @sql = concat('alter table ai auto_increment = ', @newai);
prepare stmt from @sql;
execute stmt;
deallocate prepare stmt;