我试图将值插入到表中,只能通过在另一个表上执行SELECT WHERE来找到该行的ID。以下是我的询问:
INSERT INTO wp_postmeta (meta_key, meta_value)
VALUES ('editor_review','5')
WHERE post_id=(SELECT ID from wp_posts
WHERE post_title
LIKE "%The Honest Kitchen ZEAL Grain Free Gluten Free All Life Stages Dog Food%");
有任何想法吗?
由于
答案 0 :(得分:0)
INSERT INTO wp_postmeta
(post_id, meta_key, meta_value)
SELECT id, 'editor_review', '5'
FROM wp_posts
WHERE post_title LIKE '%The Honest Kitchen ZEAL Grain Free Gluten Free All Life Stages Dog Food%'
答案 1 :(得分:0)
您可以使用INSERT INTO...SELECT
语句。
INSERT INTO wp_postmeta (meta_key, meta_value)
SELECT colA, colB
FROM wp_posts
WHERE post_title
LIKE "%The Honest Kitchen ZEAL Grain Free Gluten Free All Life Stages Dog Food%"
注意列数必须相互匹配(也是它们的数据类型)