Answer: Insert a Record
Find a detailed explanation of how to insert a record in a table using an SQL query.
Solution
The solution is given below:
MySQL
/* The query to insert a new record */INSERT INTO EmployeesVALUES (5, 'Aliza John', 65000);/* Retrieve the records in the table where EmpID is 5 */SELECT *FROM EmployeesWHERE EmpID = 5;
Explanation
The explanation of the solution code is given below:
Line 2: The
INSERT INTO
statement is followed by the table name,Employees
, which will be modified.Line 3: The
VALUES
clause specifies the values.Lines 6–8: The
SELECT
statement can be used to retrieve the records and verify the workings of our statement to insert the new record. This query outputs only the new record as per the condition. ...