[Level 3] Add row count in select of MySQL.

mysql> set @row_count;
mysql> select *, @row_count := @row_count + 1 as row_count from test;
+------+---------+-----------+
| id   | product | row_count |
+------+---------+-----------+
|    1 | cloth   |         1 |
|    2 | shoes   |         2 |
|    3 | paints  |         3 |
+------+---------+-----------+
10 rows in set (0.00 sec)
Wish this helps.
regards,
Stanley Huang

Comments

Popular posts from this blog

[Level 1] Rar tool for Solaris.

[Level 2] iif in Python