Re: Query result very long, how do I enumerate displayed results? >
>Try changing it to:
>set @RNUM = 0;
>select @RNUM := @RNUM+1 row_number, city.* from city;
I tried this using the world database and I also unsuccessfully
checked mysql's ab faq, googled and gave up and still don't
understand why the row number starts at 4080 (note: I think there
there are a total of 4079 items). How does one make it (row_number)
start counting at 1? Thank you.
mysql> select @rnum:=@rnum+1 row_number, city.* from city limit 4;
+------------+----+----------------+-------------+----------+------------+
| row_number | ID | Name | CountryCode | District | Population |
+------------+----+----------------+-------------+----------+------------+
| 4080 | 1 | Kabul | AFG | Kabol | 1780000 |
| 4081 | 2 | Qandahar | AFG | Qandahar | 237500 |
| 4082 | 3 | Herat | AFG | Herat | 186800 |
| 4083 | 4 | Mazar-e-Sharif | AFG | Balkh | 127800 |
+------------+----+----------------+-------------+----------+------------+
4 rows in set (0.00 sec)
mysql> select city.* from city limit 4;
+----+----------------+-------------+----------+------------+
| ID | Name | CountryCode | District | Population |
+----+----------------+-------------+----------+------------+
| 1 | Kabul | AFG | Kabol | 1780000 |
| 2 | Qandahar | AFG | Qandahar | 237500 |
| 3 | Herat | AFG | Herat | 186800 |
| 4 | Mazar-e-Sharif | AFG | Balkh | 127800 |
+----+----------------+-------------+----------+------------+
4 rows in set (0.00 sec) |