gpt4 book ai didi

mysql - SQL : how to SELECT strings and INSERT INTO a new table

转载 作者:行者123 更新时间:2023-11-29 23:27:50 24 4
gpt4 key购买 nike

尝试从 WordPress 表中选择某些元键/值并将它们插入到新表中。但是,目标元值是一个字符串,下面的查询仅复制“employer_address”的第一个单词。

我可以修改它以将整个选定的字符串复制到新表吗?

INSERT INTO post_addresses (id, address)
SELECT post_id, meta_value
FROM wordpress_postmeta
WHERE meta_key = 'employer_address'

最佳答案

是的,可以。假设post_id代表id,meta_value代表地址,

INSERT INTO post_addresses(id, address) 
VALUES(
(SELECT post_id FROM wordpress_postmeta WHERE meta_key = 'employer_address'),
(SELECT meta_value FROM wordpress_postmeta WHERE meta_key = 'employer_address')
)

关于mysql - SQL : how to SELECT strings and INSERT INTO a new table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26818903/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com