Last active
August 29, 2015 14:03
-
-
Save 3F/e0584698d8ed12a45912 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- example for http://stackoverflow.com/questions/24580287/#comment38085601_24580344 | |
-- MySQL AI-generator & LAST_INSERT_ID() | |
INSERT INTO `user` (`id`, `email`) VALUES (1, 'email1'); -- or your INSERT IGNORE INTO | |
INSERT INTO `user` (`id`, `email`) VALUES (2, 'email2'); | |
SELECT LAST_INSERT_ID(); -- should be 0 /note: all records successfully inserted | |
/* | |
CREATE TABLE `user` ( | |
`id` int unsigned NOT NULL AUTO_INCREMENT, | |
`email` varchar(150) NOT NULL, | |
PRIMARY KEY (`id`), | |
UNIQUE KEY `email` (`email`) -- inconsiderable for sample with 0 ^ | |
) ENGINE=InnoDB | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment