• 问题描述:请你写出更新语句,将所有获取奖金的员工当前的(salaries.to_date='9999-01-01')薪水增加10%。(emp_bonus里面的emp_no都是当前获奖的所有员工)

    方案1:where子查询

    UPDATE salaries 
    SET salaries.salary = salaries.salary * 1.1 
    WHERE salaries.to_date = '9999-01-01' 
      AND salaries.emp_no IN (SELECT DISTINCT emp_no FROM emp_bonus);
    方案2:
    UPDATE salaries s JOIN emp_bonus e ON e.emp_no = s.emp_no
    SET s.salary = s.salary * 1.1
    WHERE s.to_date = '9999-01-01';
    推荐联结查询,相对而言速度更快一些