List:General Discussion« Previous MessageNext Message »
From:Michael Dykman Date:February 25 2009 1:57am
Subject:Re: insert question
View as plain text  
On Tue, Feb 24, 2009 at 8:53 PM, PJ <af.gourmet@stripped> wrote:
> Is there a way to insert several rows into a table with one statement?
> I have this:
> $sql2 = "INSERT INTO authors
>                    (first_name, last_name, ordinal) VALUES
> ('$first_nameIN', '$last_nameIN', '1')";
>        $result2 = mysql_query($sql2, $db);
>
> I want to avoid doing another insert like:
> $sql3 = "INSERT INTO authors
>                    (first_name, last_name, ordinal) VALUES
> ('$first_name2IN', '$last_name2IN', '2')";
>        $result2 = mysql_query($sql2, $db);
>

$sql2 = "INSERT INTO authors
       (first_name, last_name, ordinal) VALUES
       ('$first_nameIN', '$last_nameIN', '1'),
       ('$first_name2IN', '$last_name2IN', '2')";


-- 
 - michael dykman
 - mdykman@stripped

 - All models are wrong.  Some models are useful.
Thread
insert questionPJ25 Feb
  • Re: insert questionMichael Dykman25 Feb