Created
October 12, 2011 12:25
-
-
Save mfr/1281094 to your computer and use it in GitHub Desktop.
unique value
This file contains hidden or 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
| CREATE TABLE `some_table` ( | |
| `id` int(4) unsigned NOT NULL AUTO_INCREMENT, | |
| `value` varchar(255) NOT NULL DEFAULT '', | |
| PRIMARY KEY (`id`), | |
| UNIQUE KEY `value` (`value`) | |
| ); | |
| INSERT INTO some_table (value) VALUES ('test') ON DUPLICATE KEY UPDATE id = LAST_INSERT_ID(id); | |
| select last_insert_id(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment