Tech Sharing

Tech Sharing

Advertisement

Insert multiple record into table

By on April 22, 2009


In SQL, basically there are two ways to Insert data into a table; one is insert it one row per time, another way is insert multiple rows at a times.


For the first method (insert one row per time) is the most common way to insert data into database that we will use normally, and the sample sql syntax as below:


Insert into table1 (col1, col2, col3)
values (value1, value2, value3)


The other insert method that we seldom use, but it may be useful if you like to copy and insert more then one row of record into a table at a time. You may include the Select statement to specify the data that you want to insert into the tables.


The SQL syntax as below:

INSERT INTO table1(col1, col2, cols3)

SELECT value1, value2, value3
FROM table2
WHERE value4 = 1998


There is another way of writing the same SQL:


Select value1, value2, value3

Into table1

From table2

WHERE value4 = 1998

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

Comments

No Responses to “Insert multiple record into table”

Write a Comment

Captcha * Time limit is exhausted. Please reload CAPTCHA.

%d bloggers like this: