Variable Visions

BIG SQL

Published Sun. Sep. 16, 2012

Use a big sql insert statement when adding multiple entries at once.

Writing the SQL statements that your article publishing forms creat helps you understand how the data is being inserted into which fields in which database tables. It also allows us the ability to insert MULTIPLE entry at once. So you don't have to spend time publishing one article at a time (if you don't want to) Say you want to republish hundreds are thousands of articles…you could hire someone all year to sit and copy/paste into a form or in phpMyAdmin, but you could work on the same SQL file and with the help of a few find and replaces you can get the job done MUCH faster. Your SQL will need to be PERFECT but once you feed it into phpMyAdmin and click go, if you receive no errors your data has been inserted.
Check out the sample code. Just ONE insert into statement with ALL your fields IN ORDER, and then one VALUE statement with MULTIPLE arrays delimited by commas until the last which is terminated by a semi-colon.

I start with some image file names that I have already uploaded to my server.

HMT-201011-COVER-WEB.jpg
HMT-201012-COVER-WEB.jpg

I then start building my INSERT INTO once and then once I get one array the way I want it I copy/paste and repeat. Then past the entire SQL statement into phpMyAdmin and hope not to see red. If you do...debug...remember to seperate by commas and terminate the last statement. Also remember to excape your quotes. Then ends up being very productive if you are inserted many, many record sets.




INSERT INTO `variable_npcomtest`.`current` (`headline`, `subhead`, `bodycopy`, `post_id`, `title`, `image`, `updated`, `tags`, `types`, `categories`, `pages`, `description`, `keywords`, `introimage`)
VALUES
("Healthcare IT magazine cover 02", "Created for a publishing firm in southwest Florida", "", NULL, "Health-IT-magazine-cover-02", "http://www.variablevisions.com/images/HMT-200807-COVER-WEB.jpg", CURRENT_TIMESTAMP, "16", "6", "2", "11", "Magazines cover", "In-Design", "http://www.variablevisions.com/images/HMT-200807-COVER-WEB.jpg"),
("Healthcare IT magazine cover 03", "Created for a publishing firm in southwest Florida", "", NULL, "Health-IT-magazine-cover-03", "http://www.variablevisions.com/images/HMT-200811-COVER-WEB.jpg", CURRENT_TIMESTAMP, "16", "6", "2", "11", "Magazines cover", "In-Design", "http://www.variablevisions.com/images/HMT-200811-COVER-WEB.jpg"),
("Healthcare IT magazine cover 04", "Created for a publishing firm in southwest Florida", "", NULL, "Health-IT-magazine-cover-04", "http://www.variablevisions.com/images/HMT-200908-COVER-WEB.jpg", CURRENT_TIMESTAMP, "16", "6", "2", "11", "Magazines cover", "In-Design", "http://www.variablevisions.com/images/HMT-200908-COVER-WEB.jpg"),
("Healthcare IT magazine cover 05", "Created for a publishing firm in southwest Florida", "", NULL, "Health-IT-magazine-cover-05", "http://www.variablevisions.com/images/HMT-201007-COVER-WEB.jpg", CURRENT_TIMESTAMP, "16", "6", "2", "11", "Magazines cover", "In-Design", "http://www.variablevisions.com/images/HMT-201007-COVER-WEB.jpg"),
("Healthcare IT magazine cover 06", "Created for a publishing firm in southwest Florida", "", NULL, "Health-IT-magazine-cover-06", "http://www.variablevisions.com/images/HMT-201008-COVER-WEB.jpg", CURRENT_TIMESTAMP, "16", "6", "2", "11", "Magazines cover", "In-Design", "http://www.variablevisions.com/images/HMT-201008-COVER-WEB.jpg"),
("Healthcare IT magazine cover 07", "Created for a publishing firm in southwest Florida", "", NULL, "Health-IT-magazine-cover-07", "http://www.variablevisions.com/images/HMT-201012-COVER-WEB.jpg", CURRENT_TIMESTAMP, "16", "6", "2", "11", "Magazines cover", "In-Design", "http://www.variablevisions.com/images/HMT-201012-COVER-WEB.jpg"),
("Healthcare IT magazine cover 08", "Created for a publishing firm in southwest Florida", "", NULL, "Health-IT-magazine-cover-08", "http://www.variablevisions.com/images/HMT-201011-COVER-WEB.jpg", CURRENT_TIMESTAMP, "16", "6", "2", "11", "Magazines cover", "In-Design", "http://www.variablevisions.com/images/HMT-201011-COVER-WEB.jpg"),
("Healthcare IT magazine cover 09", "Created for a publishing firm in southwest Florida", "", NULL, "Health-IT-magazine-cover-09", "http://www.variablevisions.com/images/HMT-201101-COVER-WEB.jpg", CURRENT_TIMESTAMP, "16", "6", "2", "11", "Magazines cover", "In-Design", "http://www.variablevisions.com/images/HMT-201101-COVER-WEB.jpg"),
("Healthcare IT magazine cover 10", "Created for a publishing firm in southwest Florida", "", NULL, "Health-IT-magazine-cover-10", "http://www.variablevisions.com/images/HMT-201105-COVER-WEB.jpg", CURRENT_TIMESTAMP, "16", "6", "2", "11", "Magazines cover", "In-Design", "http://www.variablevisions.com/images/HMT-201105-COVER-WEB.jpg"),
("Healthcare IT magazine cover 11", "Created for a publishing firm in southwest Florida", "", NULL, "Health-IT-magazine-cover-11", "http://www.variablevisions.com/images/HMT-201106-COVER-WEB.jpg", CURRENT_TIMESTAMP, "16", "6", "2", "11", "Magazines cover", "In-Design", "http://www.variablevisions.com/images/HMT-201106-COVER-WEB.jpg"),
("Healthcare IT magazine cover 12", "Created for a publishing firm in southwest Florida", "", NULL, "Health-IT-magazine-cover-12", "http://www.variablevisions.com/images/HMT-201108-COVER-WEB.jpg", CURRENT_TIMESTAMP, "16", "6", "2", "11", "Magazines cover", "In-Design", "http://www.variablevisions.com/images/HMT-201108-COVER-WEB.jpg
");