CREATE PROCEDURE reset_xyz_autoincrement
BEGIN
SELECT @max := MAX(ID)+ 1 FROM ABC;
PREPARE stmt FROM 'ALTER TABLE XYZ AUTO_INCREMENT = ?'
EXECUTE stmt USING @max
DEALLOCATE PREPARE stmt;
END $$
I took the code from here: How to Reset an MySQL AutoIncrement using a MAX value from another table?
This is the MySQL output:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BEGIN
SELECT @max := MAX(ID)+ 1 FROM ABC' at line 2