I have a database like this:
+----------+----------+------+
| username | password | time |
+----------+----------+------+
| a | b | 1234 |
| c | d | 5678 |
| e | f | 9012 |
+----------+----------+------+
Now I have to arrange this by time so I ran:
mysql_query("SELECT * FROM `table` ORDER BY `time`")
This showed me rows arranged by time in ascending order, but I have to get only username c
and e
or I have to get the last two rows from the query.
I have tried:
mysql_query('SELECT * FROM `table` ORDER BY `time` LIMIT 2')
But this showed me usernames a
and c
but I have to get the last two, how to do that?
SELECT * FROM table
ORDER BY time DESC
LIMIT 2
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments