List:General Discussion« Previous MessageNext Message »
From:Rhino Date:March 31 2005 11:15pm
Subject:Re: How does a multi-row INSERT work?
View as plain text  
There are two forms of multi-row insert. Here is a script that illustrates
both:
----------------------------------------------------------------------------
------------
use tmp;

drop table if exists target;
create table if not exists target
(id smallint not null,
 name char(10) not null,
 primary key(id));

insert into target
(id, name)
select empno, lastname
from Sample.Employee
where workdept = 'D21';

select * from target;

insert into target (id, name) values
(500, 'Smith'),
(600, 'Jones');

select * from target;

----------------------------------------------------------------------------
------------

The first insert statement copies specified rows and columns from another
table into 'target'. The second insert statement creates multiple new rows
in the 'target' table from scratch.

Rhino

----- Original Message ----- 
From: "Chris W. Parker" <cparker@stripped>
To: <mysql@stripped>
Sent: Thursday, March 31, 2005 2:46 PM
Subject: How does a multi-row INSERT work?


Hello,

I searched the archives, looked through the manual, and searched google
for info on how to actually perform a multi-row INSERT but didn't find
an answer.

Would someone please show me the syntax for this please?

I could just do a loop and INSERT the data that way but according to the
manual, a multi-row INSERT is faster.



Thanks,
Chris.

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=1


-- 
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.3 - Release Date: 25/03/2005




-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.3 - Release Date: 25/03/2005

Thread
How does a multi-row INSERT work?Chris W. Parker31 Mar
  • Re: How does a multi-row INSERT work?Jonathan Wright31 Mar
  • Re: How does a multi-row INSERT work?Dan Nelson31 Mar
    • Re: How does a multi-row INSERT work?SGreen31 Mar
  • Re: How does a multi-row INSERT work?John McCaskey31 Mar
  • Re: How does a multi-row INSERT work?Rhino1 Apr
  • Re: How does a multi-row INSERT work?Gabriel PREDA1 Apr
RE: How does a multi-row INSERT work?Chris W. Parker31 Mar
Re: How does a multi-row INSERT work?beacker31 Mar