Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在编写一个简单的 MySQL 查询来更新 WordPress 数据库。我想要做的是,任何 post_meta(自定义字段)值为 3:RW 的东西,我想将其 post_parent 设置为 4。
这是我写的但还没有运行,因为我想在运行之前验证:
UPDATE wp_posts, wp_postmeta SET wp_posts.post_parent='4' WHERE wp_postmeta.meta_value = '3:RW'
这似乎可以接受吗?
不行,你写的sql不正确。请尝试以下操作:
UPDATE wp_posts p JOIN wp_postmeta pm ON (p.ID = pm.post_id) SET p.post_parent = 4 WHERE pm.meta_value = '3:RW';
仅供参考:wp_postmeta 表必须有页面 id