I'm following a tutorial here. It keeps using '@' characters in front of stuff. Can I just confirm... does '@' identify variables within a query?
Thanks,
James
I'm following a tutorial here. It keeps using '@' characters in front of stuff. Can I just confirm... does '@' identify variables within a query?
Thanks,
James
SET is used to give the variable an initial value.
For example:
SET @row := 0;
SELECT (@row := @row + 1) AS row, name FROM table;
If we don't give the variable an initial value, it would be NULL.
It names a so-called "user variable".
Yup. MySQL's documentation has a section about user-defined variables. You typically declare them with SET in MySQL, however I've seen other kinds of SQL use DECLARE.
Ahh, this is actually how you declare variables in mysql. Look at here:
http://dev.mysql.com/tech-resources/articles/mysql-storedproc.html
The first thing we need to understand is how user variables are used and assigned values. A user variable is distinguished by having a '@' symbol in front of it, and values are assigned using the SET statement:
SELECT @myRight := rgt FROM nested_category. Is that OK to use too?