faqts : Computers : Databases : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 18 people (33%) answered Yes
Recently 1 of 10 people (10%) answered Yes

Entry

how to insert more than one item with INSERT INTO

Feb 19th, 2008 22:31
dman, Matt Chatterley, Tamas Boss, http://sturly.com


It depends very much on what you want to do.
If you're only putting in values:
INSERT INTO table1 (col1, col2) VALUES (1, 4);
Then theres no really easy way, short of writing a script in
PHP/language of your choice which will generate a list of queries for you.
If you are getting the data from another table (or query), you can
insert as many rows at once as you want:
INSERT INTO table1 (col1, col2)
SELECT col1, col2 FROM table2 WHERE col3 = 7;