I have a table student_log, and there are multiple records for a single 'rollno'.
'sno' is the auto_increment index of the student_log table.
Suppose I want to update the value of a particular field for the last(most-recent) entry of a particular student(looked up by ‘rollno’), how do I do it? My current approach does not work. I am doing this:
update student_log set timein=current_timestamp() where rollno='ST001' and
sno = (select sno from student_log where rollno='ST001' order by sno desc limit 1);
Using the subquery, I am trying to retrieve the sno of the most recent record where the student’s rollno matches. And I am trying to use it to match sno with the update statement, which isn’t working.
I know the syntax is correct, but I think it just means that MySQL does not allow update to use subqueries. Thanks. Ask me if I have missed out any information.
EDIT
tested my query, and yes its posible, or what did i miss in OPs table structure