MySQL statements to update overlapping database entries and insert new data into various tables
I was going in circles looking at your query and then I thought
... it looks like you're just updating the one table form the same table

Why can't you just use

UPDATE hashes 
SET id=@id
    WHERE hash IN ('hash1', 'hash2');


Or is this a typo?

UPDATE hashes