Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dineshsprabu/c4a964725d93c30d3334 to your computer and use it in GitHub Desktop.
Save dineshsprabu/c4a964725d93c30d3334 to your computer and use it in GitHub Desktop.
[MySQL] Adding Auto Increment Field to an Existing Table Using SELECT
/* 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