RE: [PHP] Multiple inserts as a single string?

From: Date: Thu, 02 Jun 2005 13:19:46 +0000
Subject: RE: [PHP] Multiple inserts as a single string?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-216231@lists.php.net to get a copy of this message
> > Thanks Richard that makes it clear. > > Thomas > > Hello Thomas, > > Thursday, June 2, 2005, 10:20:11 AM, you wrote: > > T> I have a bit of strange question: when wanting to insert multiple > T> records into the db, instead of looping through the set > and executing > T> mysql_query (which will then call the db n times), is it > not better > T> to concat a string with all the insert statements and let mysql > T> handle the inserting, that way we don't call the db n > times from php. > T> Does that make any difference? Inserting multiple rows with one INSERT statement is part of the SQL standard (IIRC), and MySQL supports it. INSERT INTO table(a,b) VALUES (1,1), (2,2), (3,3), ... ,(n, n) Jared

« previous php.general (#216231) next »