MainMenu

Home Java Overview Maven Tutorials

Sunday 15 January 2017

How to add Multiple rows in a table?

Add multiple rows in a table



Syntax:


Insert Into Database_name.Table_name (Column_name 1, column_name 2, column_name 3)
Values ("value_1", "value_2", "value_3"), (value_1, value_2, value_3)

So you can add multiple rows in your table
Note : If you will not give the column name then it will enter the record from first column and so on.
For example :
Suppose that there is a database "Akshat" & table of name SALARY with columns :
Emp_id int(10)
Emp_name varchar(50)
Emp_reg varchar(50)
Emp_salary int(6)
and you wish to enter four employee record at one time then your query will be
Insert Into Akshat.Salary (Emp_id, Emp_name, Emp_reg, Emp_salary) Values (01, "chandan", "E01", "50,000"), (02, "adhiraj", "E02", "40,000"), (03, "akshat", "E03", "60,000")

OR
Insert Into Akshat.Salary
Values (01, "chandan", "E01", "50,000"), (02, "adhiraj", "E02", "40,000"), (03, "akshat", "E03", "60,000")

Now three rows will be added in your table.
Note : If you will miss any column value then Error message will appear.

Tag : Use of Insert Into statement, Add multiple rows in a table, query to add multiple rows in table

No comments:

Post a Comment