Question: Insert a Record
Explore how to insert a new record into an Employees table using the SQL INSERT INTO statement. This lesson helps you practice adding data correctly, focusing on adding a new employee with specific details. Understand the syntax and execution required to update a company database effectively.
We'll cover the following...
Question
Given the following Employees table structure:
Employees
EmpID | EmpName | Salary |
1 | Susan Lee | 50000.00 |
2 | Alexa Smith | 60000.00 |
3 | Dana Amberson | 45000.00 |
4 | Sarah Ronald | 47000.00 |
Additional information
You are provided with a table named Employees that contains the following columns:
EmpID: Unique identifier for each employeeEmpName: The name of the employeeSalary: The salary of an employee
Let’s consider the Employees table. There is a task for you: you are required to update the company database to include information about a new employee, Aliza John, who is joining the team with a salary of $65,000 and an Employee ID of 5. To complete this task, you will need to use the INSERT INTO SQL statement to add this new record to the table. It’s like adding Aliza to the company’s digital family.
Let’s see how you accomplish this task!
Expected output
After inserting the record, you need to get the record of an employee having 5 as EmpID. The expected output is shown below:
EmpID | EmpName | Salary |
5 | Aliza John | 65000.00 |
Try it yourself
You can try to write a query in the following playground:
Hints
Below are some hints to help you understand these concepts better: