James Black <[EMAIL PROTECTED]> wrote on 12/08/2005 01:07:15 PM:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> In the manual (http://dev.mysql.com/doc/refman/5.0/en/insert.html) I saw
> this snippet: If you use an INSERT ... VALUES statement with multiple
> value lists
> 
> But, I thnk I am missing some information on the syntax of INSERT ...
> VALUES.
> 
> This may be what I am looking for, as I want to see if sending 100
> inserts at one time is faster than doing 100 inserts, one at a time. I
> expect it is, but I would like to get some numbers for my query.
> 
> Thank you for any help.
> 
> - --
> "Love is mutual self-giving that ends in self-recovery." Fulton Sheen
> James Black    [EMAIL PROTECTED]
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (MingW32)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
> 
> iD8DBQFDmHZTikQgpVn8xrARAnFKAJ9Co+SEny8Xl3q/NaHW528qv+JawwCeOjgj
> jCma5KTtC6w7f51LnmgECHY=
> =HIjc
> -----END PGP SIGNATURE-----
> 
> -- 

You want to look at the first syntax definition:

INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name [(col_name,...)]
    VALUES ({expr | DEFAULT},...),(...),...
    [ ON DUPLICATE KEY UPDATE col_name=expr, ... ]

You enclose each set of values in their own set of parentheses and 
separate the sets with commas.

If you have a table (tbl1) with 3 fields (fld1, fld2, and fld3) and you 
wanted to insert the following sets of values:

1,1,'red'
1,1,'blue'
1,2,'red'
1,2,'green'
10,15,'violet'

The INSERT statement would look like this:

INSERT tbl1 (fld1, fld2, fld3) VALUES 
(1,1,'red'),(1,1,'blue'),(1,2,'red'),(1,2,'green'),(10,15,'violet');

HTH!
Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

Reply via email to