题目
https://www.nowcoder.com/practice/d3b058dcc94147e09352eb76f93b3274?tpId=82&tqId=29809&rp=1&ru=%2Factivity%2Foj&qru=%2Fta%2Fsql%2Fquestion-ranking
请你写出更新语句,将所有获取奖金的员工当前的(salaries.to_date=‘9999-01-01’)薪水增加10%。(emp_bonus里面的emp_no都是当前获奖的所有员工)
create table emp_bonus(
emp_no int not null,
btype smallint not null);
CREATE TABLE salaries(
emp_no int(11) NOT NULL,
salary int(11) NOT NULL,
from_date date NOT NULL,
to_date date NOT NULL, PRIMARY KEY (emp_no,from_date));
思路
语法:UPDATE table_name SET col_name=new_value;
UPDATE salaries s RIGHT JOIN emp_bonus e ON s.emp_no=e.emp_no
SET s.salary=salary*1.1
WHERE s.to_date='9999-01-01' AND e.emp_no IS NOT NULL;