gps sago gps sago - 1 month ago 6
MySQL Question

How to use MySQL command to display last minute (i.e current minute) row from the database?

mysql> SELECT * FROM master_name;

+---------+---------------------+---------------------+-----------+----------+
| name_id | name_dateadded | name_datemodified | firstname | lastname |
+---------+---------------------+---------------------+-----------+----------+
| 1 | 2001-10-29 13:11:00 | 2001-10-29 13:11:00 | John | Smith |
| 2 | 2001-10-29 13:11:00 | 2001-10-29 13:11:00 | Jane | Smith |
| 3 | 2001-10-29 13:11:00 | 2001-10-29 13:11:00 | Jimbo | Jones |
| 4 | 2001-10-29 13:11:00 | 2001-10-29 13:11:00 | Andy | Smith |
| 7 | 2001-10-29 14:16:21 | 2001-10-29 14:16:21 | Chris | Jones |





Expected Output:




| 7 | 2001-10-29 14:16:21 | 2001-10-29 14:16:21 | Chris | Jones |

Answer
SELECT t.*
FROM master_name
WHERE id = (SELECT MAX(name_id) FROM master_name)