Why do I have to assign to a session variable for it to have the right number in a query like this:
SELECT @row_number := @row_number + 1, name FROM cities;
Instead of something like:
SELECT @row_number, name FROM cities;
In the second form it returns what I'm guessing is the last row number. Maybe even the value of a COUNT(*). It's almost as if the value is somehow closed over. What is going on in these two queries?