![](/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.