update table based on values from another table sql