sql data editor (join two different sql files)

Discussion in 'MySQL' started by Istvan, Mar 10, 2008.

  1. #1
    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 :eek:

    Thanks
     
    Istvan, Mar 10, 2008 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    I can do this for you

    Regards

    Alex
     
    kmap, Mar 13, 2008 IP
  3. Istvan

    Istvan Well-Known Member

    Messages:
    1,544
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    175
    #3
    for free? :D I'm already doing that with excel because I haven't found any program.
     
    Istvan, Mar 13, 2008 IP
  4. articledirectory

    articledirectory Peon

    Messages:
    1,704
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Im not much of a database expert but could you change the database tables etc in phpmyadmin so that they both match?
     
    articledirectory, Mar 18, 2008 IP
  5. Istvan

    Istvan Well-Known Member

    Messages:
    1,544
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    175
    #5
    Thanks, I'll try this way next time.
    Now I have already "converted" it with excel/word :)
     
    Istvan, Mar 19, 2008 IP
  6. hyper

    hyper Peon

    Messages:
    1,565
    Likes Received:
    214
    Best Answers:
    0
    Trophy Points:
    0
    #6
    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! :)
     
    hyper, Jun 14, 2008 IP
  7. Istvan

    Istvan Well-Known Member

    Messages:
    1,544
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    175
    #7
    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) :)
     
    Istvan, Jun 23, 2008 IP
  8. AltaMind

    AltaMind Active Member

    Messages:
    331
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    63
    #8
    Thank you Istvan!
     
    AltaMind, Sep 29, 2008 IP
  9. articledirectory

    articledirectory Peon

    Messages:
    1,704
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #9
    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.
     
    articledirectory, Sep 30, 2008 IP
  10. chisara

    chisara Peon

    Messages:
    141
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #10
    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.
     
    chisara, Sep 30, 2008 IP