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:

[text]
Set @a = 0;
UPDATE my_table SET id=@a:=@a+1
[/text]

Check out the docu and examples:
http://dev.mysql.com/doc/refman/5.0/en/user-variables.html