What's the difference between accessing a variable with @ or without?
The @ makes it a user defined session variable. Otherwise it would be locally scoped variable (in a stored procedure), you would have to DEFINE your local before you can SET it. You could also set a global system variable (with SET GLOBAL or SET @@global) if you wanted to. As well as a session system variable with SET SESSION var or SET @@session var or SET @@var.
More details about SET from the documentation: If no modifier is present, SET changes the session variable (that's why you DEFINE your locals in the stored procedure first). If you set several system variables, the most recent GLOBAL or SESSION modifier in the statement is used for following variables that have no modifier specified.
More (and some good examples) here:
That notation is used for user-defined variables, as explained here: http://dev.mysql.com/doc/refman/5.0/en/user-variables.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With