Adding additional information to table.

Discussion in 'MySQL' started by sizzlefire, Apr 18, 2010.

  1. #1
    Hello everyone, I am having a bit of a database problem. I have a large number of tables that have a filename in them, which is something like filename1992.mp3 and I need to mass modify so that instead of them all saying something like filename1992.mp3, filename1993.mp3 I need them to be http://example.com/1992/filename1992.mp3, http://example.com/1993filename1993.mp3 etc etc.

    Basically I need to mass insert additional code in front of specific tables in my database based on a specific date located in the table. There are only 15 different dates, however there are thousands of tables, so can anybody please lead me in the right direction on this?

    EDIT: I have found the command "SELECT * FROM flamplayer_musics WHERE filename_music LIKE "%1995%"" however how can I use another command with another command that will let me add information to the front of a table?
     
    Last edited: Apr 18, 2010
    sizzlefire, Apr 18, 2010 IP
  2. NemoPlus

    NemoPlus Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello,

    I would try something with the update query.

    UPDATE flamplayer_musics
    SET filename_music  = CONCAT("http://www.example.com/", filename_music )
    Code (markup):
    You will probably need something more complex than a simple concatenate. You will probably need to combine it with some kind the substring function MID. List of mysql string functions: dev.mysql.com/doc/refman/5.0/en/string-functions.html

    Or you might do one per year number.

    UPDATE flamplayer_musics
    SET filename_music  = CONCAT("http://www.example.com/1995/", filename_music )
    WHERE filename_music LIKE "%1995%";
    
    UPDATE flamplayer_musics
    SET filename_music  = CONCAT("http://www.example.com/1996/", filename_music )
    WHERE filename_music LIKE "%1996%";
    
    UPDATE flamplayer_musics
    SET filename_music  = CONCAT("http://www.example.com/1997/", filename_music )
    WHERE filename_music LIKE "%1997%";
    
    Code (markup):
    Good luck.
     
    NemoPlus, Apr 20, 2010 IP
  3. cDc

    cDc Peon

    Messages:
    127
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I would like to post one more additional word of advice something that has bitten me before - I always add a new column for the new version of the data when doing these kind of updates then If you make a mistake you will still preserve you original data.
     
    cDc, Apr 22, 2010 IP