Friends I unable to understand the following sql code.will please explain each and every term in this. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Friends I unable to understand the following sql code.will please explain each and every term in this.

This is the code: SET @num := 0; UPDATE your_table SET id = @num := (@num+1); ALTER TABLEĀ tableNameAUTO_INCREMENT = 1;

9th Feb 2021, 3:44 AM
M Raghavendar
1 Answer
0
I don't understand the last line, it's been a bit since I did anything with sql. But I'll give the rest a shot. SET does what it says. It sets var to the next statement. @num is a variable that I believe is the location of the cell we are editing. After that you update the table you are working in such that the id (or name) at the cell is one more than the cell value.
9th Feb 2021, 1:22 PM
Mark McGuire
Mark McGuire - avatar