Search code examples
mysqlwordpressmeta-key

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?

Solution

  • 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