![](/img/trans.png)
[英]MySQL - Automatic copying data from one column to another in one table
[英]MySQL - Copying data from one table to another
我正在嘗試從一行復制數據,並使用某些值創建一個新行。
我想我基本上可以使用它,但是我想將meta_key
值設置為meta_key
,而不要復制值“ articles”
然后,使用相同的post_id創建新行?
有任何想法嗎?
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')
我想你只想要這個:
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%";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.