Ad Code

Updating last entry of a particular ID in MySQL

mysql> UPDATE student_log
    -> SET timein=current_timestamp()
    -> WHERE rollno='ST001'
    -> ORDER BY sno DESC
    -> LIMIT 1;
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> SELECT * FROM student_log;
+-----+--------+---------------------+
| sno | rollno | timein              |
+-----+--------+---------------------+
|   1 | st001  | 0000-00-00 00:00:00 |
|   2 | st002  | 0000-00-00 00:00:00 |
|   3 | st001  | 2012-07-11 12:05:23 |
+-----+--------+---------------------+
3 rows in set (0.00 sec)

Post a Comment

0 Comments