Use Excel to generate a whole crapload of SQL queries
Tuesday, January 19th, 2010I had to update a whole lot of rows, and instead of sitting down and doing some ridiculous export and re-update, I figured I’d just write an SQL query in an Excel Concatenate statement and use the ids in the spreadsheet. WAH LA
First 2 columns are A : the id and B : the value I want to replace.
In column C, I put:
=CONCATENATE("UPDATE tablename SET fieldname='",B1,"' WHERE idfield=",A1,";")
Then, just copy and paste that cell all the way down, copy the queries, and paste them into a phpMyAdmin SQL text box and run.




