Skip to content

MySQL User defined Variables - good thing to know!

Have you ever heard of user defined variables in MySQL? I hadn’t and nearly freaked out when I found out. That’s the thing I was always looking for, that’s so cool, and fasten up your SQL live a lot!

Now, renumbering a table is as easy as never before:

Set @a = 0;
UPDATE my_table SET id=@a:=@a+1

Check out the docu and examples: