Go back to the main page

Properly set up an auto incremented composite key with MySQL

This article is over 2 years old. Proceed with caution.

Regards ♨ – Minimul

 

Remember to put the "auto_increment" row SECOND and the engine must be MyISAM.

CREATE TABLE `issue_numbers` (
  `list_id` int(11) NOT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
    PRIMARY KEY (`list_id`,`id`)
    ) ENGINE=MyISAM  ;
    

Comment on this article?