1

I'm trying to copy the data from one row and create a new one with some of the values.

I think I have it basically working BUT I want to set value of meta_key to additional_articles_0_article_url, and not copy the value "articles"

And after that occurs, create new row, with using the same post_id?

Any ideas?

INSERT INTO tpl_postmeta (post_id, meta_key, meta_value)
SELECT m.post_id, m.meta_key, m.meta_value
FROM tpl_postmeta m
WHERE m.meta_key = "articles" AND m.meta_value LIKE "%.com%";

INSERT INTO tpl_postmeta(post_id, meta_key, meta_value) 
VALUES ('same post_id as above','_additional_articles_0_article_title', 'New Article')

1 Answer 1

2

I think you just want this:

INSERT INTO tpl_postmeta (post_id, meta_key, meta_value)
    SELECT m.post_id, 'additional_articles_0_article_url', m.meta_value
    FROM tpl_postmeta m
    WHERE m.meta_key = "articles" AND m.meta_value LIKE "%.com%";
Sign up to request clarification or add additional context in comments.

2 Comments

Just about to hit enter :)
Thanks, I just added one additional question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.