title: Updating last entry of a particular ID in MySQL
body: <p>I have a table <code>student_log</code>, and there are multiple records for a single <code>'rollno'</code>.</p>
  
  <p><code>'sno'</code> is the auto_increment index of the student_log table. </p>
  
  <p>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:</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>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.</p>
  
  <p>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.</p>