Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
WHEN WE USE THE ADRESS OF THE FEILDS W HAVE DECLARED IN SQL TABLE.

What I have tried:

CREATE TABLE EMP(NAME VARCHAR2(10),ID NUMBER(3));
TABLE IS CREATED
INSERT INTO EMP VALUES('&NAME',&ID);
ENTER NAME
ENTER ID
AFTER GIVINGG THE TWO FIELDS ONCE THE CODE EXCUTES AND ONE RWO IS CREATED.
BUT I WANT TO GIVE MULTIPLE VALUES AFTER THE 1ST ROWS IS CREATED(i.e FOR THE 2ND ROW,3RD VALUES)HOW TO DO THAT.
Posted
Updated 8-Aug-18 8:02am
Comments
RedDk 8-Aug-18 13:45pm    
INSERT INTO dbo.x VALUES('Explicit value','Explicit value') would insert two records ... or as you say INSERT INTO EMP VALUES('xylem',1),('phloem',2),('cantbeatum',3),('joinem',4) ... yes?

1 solution

See the syntax of the INSERT statement: INSERT (Transact-SQL) | Microsoft Docs[^] It's in the section " Inserting multiple rows of data"
SQL
INSERT INTO TableName (list of columns) 
VALUES (list of values for row 1), 
       (list of values for row 2),
       (list of values for row 2),
       (list of values for row 2), 
       (list of values for row 2), 
       (list of values for row 2)
 
Share this answer
 
Comments
Dinesh Sahoo 8-Aug-18 15:17pm    
how to use max function with other feilds to retrive data.
the command is not working for retriving the data like first_name,last_name with the highest paid employee.
command:-
select first_name,last_name from employee where salary=max(salary);
error :
group function is not allowed here.
Zalak Artist 9-Aug-18 8:38am    
select first_name, last_name from employee where salary =(select max(salary) from employee)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900