Updating tables in sql from another table