i cannot update a column by using a cloumn in the same table in mysql -


i want calculate letter grade using average column.

i tried code:

update students set letter_grade='ba'  (average- (select avg(average)from   students )) > 20  , (average-(select avg(average)from students)) < 25; 

but gives following error: you cant specify target table 'students' update if clause.

it seems mysql not allow update table using select same table. how can solve problem?

try this

update students set letter_grade='ba' group average having (average - avg(average)) > 20 , (average - avg(average)) < 25 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -