How do I INSERT multiple entries at once into an MySQL database
-
13-09-2019 - |
Question
I have to create a histogram/dictionary of all words found in parsing an html file. This includes a dictionary of all words found, and a histogram of their frequency.
I can't think of how to do this with PHP/MySQL because there could be potentially 2000 words that would have to be inserted at once.
Any ideas?
Solution
If you have that many entries, create a text file and use the LOAD DATA INFILE
command.
OTHER TIPS
Just insert multiple records at one time, but, if one has an error the entire insert will fail.
http://www.desilva.biz/mysql/insert.html
"INSERT INTO beautiful (name, age)
VALUES
('Helen', 24),
('Katrina', 21),
('Samia', 22),
('Hui Ling', 25),
('Yumie', 29)";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow