简体   繁体   中英

mysql query doesnt work

I have a problem with a query in mysql. It's from a wordpress blog and a try to set the title of each post als meta_key and meta_value

INSERT  `wordpress_postmeta` (`meta_id` ,`post_id` ,`meta_key` ,`meta_value`)
VALUES ( '',`ID` , _yoast_wpseo_focuskw, `wordpress_posts`.`post_title`) 
(`wordpress_posts`.`ID` , _yoast_wpseo_focuskw, `ewordpress_posts`.`post_title`)
SELECT * FROM ewordpress_posts WHERE (`wordpress_posts`.`post_status` = 'future'))
  1. is it possible to do this in one query?
  2. where is my fault?

try that :

INSERT INTO `wordpress_postmeta` (`meta_id` ,`post_id` ,`meta_key` ,`meta_value`)
SELECT '',t1.`ID` , t2._yoast_wpseo_focuskw, t1.`post_title` 
FROM ewordpress_posts t1, ekwh_wordpress_postmeta t2
WHERE `post_status` = 'future' 

this assuming _yoast_wpseo_focuskw is in your table ewordpress_posts

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM