select @n := 0;
select @n:=@n+1 as rec, contactname from contact;
select @n:=@n+1 as rec, contactname from contact;
The first statement initializes the variable "n". The second statement uses the variable on the first statement.
A sample output record from the select statement is as follows:
| rec | contactname |
| 1 | Marilou |
| 2 | Ivan |
| 3 | Harris |
| 4 | Nelson |
| 5 | Peter |
RSS Feed 


0 comments:
Post a Comment