I have a table named 'Student' with columns `Name`, `Role`, `Class` and `Subject`.

I have another table named 'StudentClass' with columns `Name` and `Class`. I have to insert `Name` and `Class` columns of 'StudentClass' table from 'Student' table if the `Name` and his corresponding `Class` do not exist in the 'StudentClass' table. If `Name` exist in the 'StudentClass' table but its corresponding `Class` value is different for that row, then update the `Class` value for that row in 'StudentClass' table

I can't simply truncate the 'StudentClass' table and insert `Name` and `Class` from 'Student' table because I have keep track of any change made in the 'StudentClass' table. 

So is there any mySQL query which inserts `Name` and `Class` from 'Student' table into 'StudentClass' table if the `Name` and its corresponding `Class` do not exist in 'StudentClass' table else update the row if `Name` exist but its corresponding `Class` value is different.