I went through the previous answer like this, but it gives me the following error : You can't specify target table 'table_name' for update in FROM clause.
I have a table with say 3 columns (id -> auto increment primary id) :
id, roll_no and attendance
And for selected roll numbers having many entries each, except the first entry I want to update all entry attendance field as P.
The query which I wrote is following :
UPDATE tbl_class_attendance 
   set attendance = 'P' 
 where id NOT IN 
   (Select min(id) 
      from tbl_class_attendance 
     WHERE roll_no IN ('25', '45', '55') 
     GROUP 
       BY roll_no;
But it gives me the above error. I also went through other answers asking to use two select queries but there the answer I didn't find completely easy to understand as well as difficulty in executing for my selected list of roll numbers.
So, is there a way to update?
EDIT : Answer given below
 
    