UPDATE vn.invoiceOut SET id = (SELECT MAX(id) + 1 FROM vn.invoiceOut) WHERE id = 0; ALTER TABLE vn.invoiceOut MODIFY COLUMN id int(10) unsigned auto_increment NOT NULL;