Need an SQL Query, For moving content [Paying $20 for a solution]

Discussion in 'MySQL' started by podda999, Nov 9, 2009.

  1. #1
    Hey all, i am pretty new to the SQL scene and need a little help, i will be paying $20 to the first person who can supply me with an SQL command to do the following.

    HERE IS AN IMAGE TO HELP YOU UNDERSTAND WHAT I WOULD LIKE

    [​IMG]

    DIRECT LINK

    http://i35.tinypic.com/rct5af.jpg

    I have a wordpress database which i have full local access to.
    I would like to update the posts within the field post_content field located in the table wp_posts, this will be updated with data from the field meta_key where meta_value = embed. This needs to update all the fields with the meta_value embed take the data from that field ans put it in the post_content field within the wp_post table. The update should update the posts with the same post_id. Its called post_id within the wp_post meta table and within the wp_posts table its called ID.

    What i am trying to achive is to move the content from within the wp_postmeta table to the post_content field within the wp_posts table. At the moment if i change wordpress themes the theme wont know to look for the custom field embed. So i would just like to move the data to the content field. If you have any confusion what i am trying to do please PM me.

    First person to give me a query which works gets $20 Have fun. Contact for help where needed.

    EDIT:
    I can send dump via request. If needed, or i can try the query myself on a backup database.
     
    Last edited: Nov 9, 2009
    podda999, Nov 9, 2009 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Following will help..

    Use SELECT query to test whether your final output is as desired. if post_content and meta_value columns in result of SELECT query are as per your needs, then only execute UPDATE query and make sure to take backup of tables before doing so..

    Let me know if i have missed out any condition and accordingly I will provide with new query :)

    
    SELECT post_id, ID, post_content, meta_value FROM wp_posts JOIN wp_postmeta ON ID = post_id AND meta_key = 'embed'
    
    UPDATE wp_posts JOIN wp_postmeta ON ID = post_id AND meta_key = 'embed' SET post_content = meta_value
    
    Code (markup):
     
    mastermunj, Nov 9, 2009 IP
  3. podda999

    podda999 Greenhorn

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    Ill test this out tonight, if it works ill PM you for payment details Thanks.
     
    podda999, Nov 10, 2009 IP