Welcome! Log In Create A New Profile

Advanced

INSERT INTO multiple rows

Posted by Cameron 
Announcements Last Post
Announcement myUnisa availability 21 to 24 March 2019 03/17/2019 02:24PM
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
INSERT INTO multiple rows
September 04, 2007 11:43PM
Hello.

I'm asking if anyone knows if there is a way to insert multiple values in a single insert query.

Instead of a single insert query for each row,

INSERT INTO mytable
(a, b, c, d)
VALUES('Item 1', 200, #25-dec-1999#, 499);

multiple values for multiple rows, something on the lines of: (erroneous, but to illustrate the point)

INSERT INTO mytable
(a, b, c, d)
VALUES('Item 1', 200, #25-dec-1999#, '499')
VALUES('item 2', 228, #31-dec-2009#, '300');

It would really make thing a little easier for me if someone could point it out to me.

-------------------------------------------------------------------------------
CameronTaljard

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Scott Adams, 'The Dilbert Principle'
Anonymous User
Re: INSERT INTO multiple rows
September 05, 2007 09:37AM
Different databases each treat this in a different manner. If you asking about Access,
then I dont know cause I dont really use it but for SQL server, you have several options.
For example if you need to add values from a file, the basic syntax is

 
BULK INSERT 
   table_name 
      FROM 'data_file'
      WITH [options]

If the values come from another table, then you can use something like

INSERT destination_table
    SELECT value1, value2, value3, value4 
    FROM Source_table WHERE [conditions];

There are many other options including the bulk load utility and GUI tools

Hope this helps or points you in the right direction

Bini
Re: INSERT INTO multiple rows
September 05, 2007 07:13PM
Thanks Bini,

Yes, speciffically for the module; Access, I guess it would be easier if the data was entered through a form, directly in the table, or from another table as you said.

It seems like a logical thing to do, multiple entries into a single insert statement.

It would also be great if this module made use of SQL Server or mySQL with/instead of Access, as SQL express 2005 is freely available and more likely to be used in a business enviroment.

But SQL is SQL and probably the emphasis is on the language and not the applicationn

What do you think?
Anonymous User
Re: INSERT INTO multiple rows
September 05, 2007 07:58PM
I dont mind the course being in Access course much of SQL is the same in all the relational databases but there are subtle differences between the various products. To be honest though, I havent really read the prescribed textbook so I cant make an honest assessment of this module. I guess the time to start is now since the exams are around the corner
Re: INSERT INTO multiple rows
September 05, 2007 11:06PM
Exam are soon. The time is now to get ready.

LOL, I've just made a countdown clock thingy in access from queries & macros, letting me know how many days till each exam.

I hear you on the subtle differences, Express & Access both MS product and still have differnt wildcrards,

Express -
SELECT [patient_name]
FROM [PATIENT]
WHERE [PATIENT_NAME] LIKE '%B%';

Access -
SELECT patient.patient_name
FROM Patient
WHERE patient.patient_name LIKE "*b*";

What ever happened to consistency?
Sorry, only registered users may post in this forum.

Click here to login