How to insert multiple rows in one single query??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shubham.amola
Forum Newbie
Posts: 8
Joined: Mon Jan 19, 2009 11:57 pm

How to insert multiple rows in one single query??

Post by shubham.amola »

I want to insert multiple rows in a table in one single query. Insert query is working when i have to insert single row but when it comes to insert multiple rows its taking the value of last rows...

this is the query i am using

INSERT INTO [table]
( [field1], [field2], [field3] ) VALUES
( '[value1.1]', '[value1.2]', '[value1.3]' ),
( '[value2.1]', '[value2.2]', '[value2.3]' ),
( '[value3.1]', '[value3.2]', '[value3.3]' ),


Any suggestions
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: How to insert multiple rows in one single query??

Post by jaoudestudios »

You dont need the last comma (,).

Examples
http://dev.mysql.com/doc/refman/5.1/en/insert.html
Post Reply