I agree with you that
select 1 += 1
would be incorrect, because += is a compound addition/assignment operator and one cannot assign a value to the integer literal
1
- it's not a variable! However, if you try the usage I give in my answer (
set @row_num += 1
) you will find it works perfectly well provided
@row_num
has been initialised to a non-null value. :) I've updated my answer to provide a link to the official documentation of the += operator. —
philosophicles 41 mins ago