Increment counter in MySQL
Another specialist thing, but here we go:
mysql> select @m:=0;
+-------+
| @m:=0 |
+-------+
| 0 |
+-------+
1 row in set (0.00 sec)
mysql> update image_descriptions set ordering=(@m:=@m+1)
-> where category='gallery';
Query OK, 35 rows affected (0.00 sec)
Rows matched: 35 Changed: 35 Warnings: 0
ie. set a variable to 0 then increment inside the SQL..
