Created
February 8, 2016 12:42
-
-
Save dineshsprabu/c4a964725d93c30d3334 to your computer and use it in GitHub Desktop.
[MySQL] Adding Auto Increment Field to an Existing Table Using SELECT
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
/* This can be used if the table doesn't have an existing Primary Key */ | |
SELECT @s:=@s+1 as id, <table-name>.* from <table-name>, (SELECT @s:= 0) as s; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment