Core iTOps Tube

Friday, 29 June 2012

Moving columns around

This is a mysql night mare that I cant seem to wrap my head around. Any shell based answers is appreciated as I dont know Perl and all I would do would be blindly copy & paste !


1389685 INSERT INTO Opera_ShirtCatlog(col1,col2) VALUES (1,'TEST1'),(2,'TEST2');

1389675 INSERT INTO Opera_ShirtCatlog_Wom(col1, col2, col3) VALUES (9, 'Siz12, FormFit', 'Test');


INSERT INTO Opera_ShirtCatlog(col1,col2,FIRSTCOL) VALUES (1, 'TEST', 1389685);

INSERT INTO Opera_ShirtCatlog_Wom(col1, col2, col3, FIRSTCOL) VALUES (9, 'Siz12 FormFit', 'Test', 1389675);

As you can see above, the task at hand is this that I want to move the first column as part of the INSERT statement's LAST COLUMN before the closing paranthesis. I am loosing my mind trying to figure this out as I can use sed to hold the variable and then how am I supposed to substitute this only especially when it has to avoid the first closing bracket as thats table definition ... also if I use awk then how do I do a regex substitution ? Any help is sincerely appreciated.



No comments:

Post a Comment