Hello whirlco,
The quick answer is - you wouldn't do this with one insert command.
You would need to create an insert statement for each record, and the
resulting set of instructions can be considered as one sql statement.
I shortened the table row names so you can view the code on one line.
INSERT INTO contacts VALUES(na,lna,a,lo) VALUES
('Jim','Smith','50','Ohio');
INSERT INTO contacts VALUES(na,lna,a,lo) VALUES
('Tim','Jones','22','Alaska');
INSERT INTO contacts VALUES(na,lna,a,lo) VALUES
('Ron','Wales','95','Maine');
INSERT INTO contacts VALUES(na,lna,a,lo) VALUES
('Pat','Donut','18','Iowa');
You would keep going until you were done. Of further note, if you are
inserting a value (even if it is null) for each field that you have,
you can lose the initial values assignment, as the data falls into
place on it's own. Example:
INSERT INTO contacts VALUES ('Jim','Smith','50','Ohio');
INSERT INTO contacts VALUES ('Tim','Jones','22','Alaska');
INSERT INTO contacts VALUES ('Ron','Wales','95','Maine');
INSERT INTO contacts VALUES ('Pat','Donut','18','Iowa');
Null fields can be defined by simply using empty quotes. Example:
INSERT INTO contacts VALUES ('','Smith','50','Ohio');
INSERT INTO contacts VALUES ('Tim','','22','Alaska');
INSERT INTO contacts VALUES ('Ron','Wales','','Maine');
INSERT INTO contacts VALUES ('Pat','Donut','18','');
I really didn't use a search strategy to find this answer, as I run a
few websites with PHP/Mysql backends. There are many good reference
sites, and this page at the Mysql site is a good read:
http://www.mysql.com/doc/en/Loading_tables.html
It makes mention of the LOAD DATA statement, which really, to me makes
for just as much, if not more work on our ends. The industry standard
is exactly what you see above :-)
I hope this answers your question. Should you need clarification,
please ask before rating this answer, as I would love to offer more
assistance.
Thanks for the question!
SgtCory |