Reputation: 1801
Hiii..
I had created one table in mysql...and inserted about 320 records in that table. Now I altered that table and added one auto_increment
field. Now it is showing null
value for that field in all records.
Guys please tell me trick to update all 320 record with 1 to 320 in that field.
update formData set ID = (select @rownum := @rownum + 1 AS rank from formData t, (select @rownum := 0)r);
Upvotes: 0
Views: 22
Reputation: 2154
I think below SQL useful to you.
SET @rank:=0;
UPDATE formData
SET ID=@rank:=@rank+1
Thank you.
Upvotes: 1