Issue
I added a new row to my Payable table named id (int 5) and want to change the primary key from stock (int 5) to id. However when I created the id row sql inserted a 0 value for each row. How do I alter the table, giving each row an auto incremented value starting at 10001 and make that the primary key?
Solution
Something like this (since MySQL allows in-line assignments):
SET @var = 10000;
UPDATE Payable
SET id = (@var := @var + 1);
Answered By - PM 77-1
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.