Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




Insert Multiple records with single Insert statement

For entering data in table we will write below command.

insert into persons
(
p_id, First_Name, Last_Name, Address, city
)
values
(
'2', 'Shyam', 'Kumar', 'Address2', 'city2'
)

insert into persons
(
p_id, First_Name, Last_Name, Address, city
)
values
(

'3', 'ghanShyam', 'Kumar', 'Address3', 'city3'
)


It will enter 2 records in database. The same functionality may be achieved by Single Insert Statement.

Solution:

insert into persons
(
p_id, First_Name, Last_Name, Address, city
)
select '2', 'Shyam', 'Kumar', 'Address2', 'city2'
unial all
select '3', 'ghanShyam', 'Kumar', 'Address3', 'city3'

It will insert two records in table.

Share this article   |    Print    |    Article read by 1247 times
Author:
Rohit kakria
I am software developer
Related Articles:
Related Interview Questions: