Hi, I'm a sql newbie so please help me I have some sql files that are good for different scripts, so they are not in the same format. How can I change this to make them work? I try to explain better... Sample from the first file INSERT INTO `tab1` VALUES (101, 'Title1', 'Desc1', '101', '2', 3, 1, '', '500', '500', '', '1', '1'); INSERT INTO `tab1` VALUES (102, 'Title2', 'Desc2', '102', '0', 3, 1, '', '500', '500', '', '1', '1'); ... Code (markup): Sample from the second file INSERT INTO `tab1` VALUES ('', 'file3', 'img', 1, 1, '', 'Title3', 'Desc3', '101', 500, 380, 6, 0, 'stat', 'SWF', 'date', 0, 0, 0, '0', '0', '1'), INSERT INTO `tab1` VALUES ('', 'file4', 'img', 1, 1, '', 'Title4', 'Desc4', '101', 600, 370, 6, 0, 'stat', 'SWF', 'date', 0, 0, 0, '0', '0', '1'), ... Code (markup): I have to take from the second file only the fields I need "Title", "Desc", ... and format them as the first file. Can you suggest me a free program to make this? Last time I have convert it in excel+word but that's not a fast procedure Thanks
Im not much of a database expert but could you change the database tables etc in phpmyadmin so that they both match?
converted it with excel/word ? a mysql database ? Can you please share how you did that ? This could be useful for me in the future projects Thanks in advance!
Well, I have copied the file in Word, removed the first part till the "(" and the last part ")," with Find & Replace. Then I have converted the file to table dividing it at "," and copied the table to excel. Now you can move columns and row as per you need (you can keep it in Word if you prefer). Finally you have bring it back to Word and convert table to text dividing it with ",". Last step is to add a col at start and one at the end (filling with the part you have removed during the first step. To do this you can copy the file to excel and then re-import to word)
you can also do the same with "context" its a free text editor and capable of editing files 100meg+ which word/excel may have trouble with.
Since your asking for a program you migth be interested in automating this. If that is the case my suggestion would be to: 1) Load the second file into your database server. 2a) If possible use alter table drop / add column statements to create the same column order as the first file. 2b) If not possible create a second table temptable with the same column order as the first file and do something akin to a select tab1 ... insert temptable 3) drop the tab1 table 4) rename the temptable-> tab1 5) Export the current tab1 and drop the database. If you have some working SQL knowledge and have the manuals of your Database server you should be able to automate this yourself fairly easy.