Updating mass rows (adding some code) and merging rows, possible?

Discussion in 'MySQL' started by dadaas, Mar 23, 2010.

  1. #1
    Hi, im converting my databases to wordpress and i have one problem.

    I have pictures in one folder but on old database this is just a filename. What i need is a code like <img src="myurl.com/filenameindatabase.jpg"> So i need to insert image code with url before and after a filename, this sound like a big problem and im not sure if this will work, but if anyone know any solution or sql command let me know.

    As well can i merge two columns in one? i have description and this file column after i update my file column with image code i would like to merge them and then convert this one column as post_content column in wordpress...

    thanks upfront for all advices and help.
     
    dadaas, Mar 23, 2010 IP
  2. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #2
    
    UPDATE TableName SET pics_FieldName=CONCAT('<img src="myurl.com/',pics_FieldName,'" />');
    
    Code (markup):
    WP merging solution is analogical.
    Regards :)
     
    Last edited: Mar 24, 2010
    koko5, Mar 24, 2010 IP
  3. dadaas

    dadaas Well-Known Member

    Messages:
    1,298
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    160
    #3
    ok i know what variables i need to change tablename and myurl, but where do i put my column where filenames are? Or how i do that? How to use picsfieldname?
     
    dadaas, Mar 24, 2010 IP
  4. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #4
    This is the column name where pictures are stored now as simple filenames. I mean CREATE TABLE TableName(id int,pics_FieldName varchar(255)..
    You must do a backup.
    Next, before update you can try the query:
    
    SELECT CONCAT('<img src="myurl.com/',pics_FieldName,'" />') AS FNAME FROM TableName LIMIT 1;
    
    Code (markup):
    to check how it will do update using update statement.
     
    koko5, Mar 24, 2010 IP
  5. dadaas

    dadaas Well-Known Member

    Messages:
    1,298
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    160
    #5
    Wow you did it again. thanks mate!!!
     
    dadaas, Mar 25, 2010 IP