NEWSubscribe to Receive Free E-mail UpdatesSubscribe

What Is SQL INSERT Statement And How To Use

The SQL INSERT statement allows you to insert a single record or multiple records into a table.

The syntax for the SQL INSERT statement is:
INSERT INTO table (column-1, column-2, ... column-n) VALUES (value-1, value-2, ... value-n);

Using VALUES keyword example:
The simplest way to create an SQL INSERT statement to list the values using the VALUES keyword.
INSERT INTO employees (emp_id, emp_name) VALUES (4582, 'Ravi');
This SQL INSERT statement would result in one record being inserted into the employees table.

Using sub-selects example:
You can also create more complicated SQL INSERT statements using sub-selects.
INSERT INTO employees (emp_id, emp_name) SELECT account_no, name FROM customers WHERE city = 'Delhi';
By placing a "select" in the SQL INSERT statement, you can perform multiples inserts quickly. With this type of insert, you may wish to check for the number of rows being inserted.