Created
August 14, 2018 05:50
-
-
Save CMCDragonkai/8e5ba2394fb0e31971ca2784d969e843 to your computer and use it in GitHub Desktop.
Import Rows with Auto-Increment ID Used on Multiple Fields #sql #mysql
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
LOCK TABLES test WRITE; | |
SET @next_id = ( | |
SELECT AUTO_INCREMENT | |
FROM information_schema.TABLES | |
WHERE TABLE_SCHEMA=DATABASE() AND | |
TABLE_NAME='test' | |
); | |
INSERT INTO test | |
(id1, id2, id3) | |
VALUES | |
(@next_id, @next_id, @next_id), | |
(@next_id + 1, @next_id + 1, @next_id + 1); | |
SET @next_id = NULL; | |
UNLOCK TABLES; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment