0

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?
Jason Heo
  • 9,956
  • 2
  • 36
  • 64
Joern
  • 3
  • 1

1 Answers1

0

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

echo_Me
  • 37,078
  • 5
  • 58
  • 78
  • There are two tables 1. ekwh_wordpress_posts 2. ekwh_wordpress_postmeta mom... I'm looking for the fields – Joern Jun 30 '14 at 10:43
  • check edited answer , added second table if this what you want. – echo_Me Jun 30 '14 at 10:47
  • table1: ekwh_wordpress_post table2: ekwh_wordpress_postmeta in table post i need the field post_title and copy this title to postmeta with a new meta_id (autoincrement) post_id (like post_id from table 1 post) meta_key (like post_title from table1_post) and meta_value (like post_title from table1_post) – Joern Jun 30 '14 at 10:49
  • doenst work. I only need ID and post_title from ekwh_wordpress_post – Joern Jun 30 '14 at 10:54