← All Exercises

SQL INSERT and UPDATE

basicsql~15min

Background

INSERT adds new rows to a table, and UPDATE modifies existing rows matching a WHERE condition.

Problem

Write SQL statements to insert a new employee and then update salaries for all employees in the Sales department.

Input

An employees table with id, name, department, salary columns.

Output

One new row inserted and all Sales department salaries increased by 10%.

Sample tests

Sample 1

Input: insert Alice in Sales, update Sales salaries +10%
Expected: Alice added, Sales employees get 1.1x salary

Your solution

Learning objective

Learn INSERT INTO VALUES, UPDATE SET, and the importance of WHERE in UPDATE.