samoht Posted November 3, 2009 Share Posted November 3, 2009 hello all, I need to run a query of one table to get all on my records that I need to insert a row for in another table. the table that I first need to query has all my post ID's that have the category 104 the table structure is as follows: `wp_term_relationships` ( `object_id` bigint(20) unsigned NOT NULL default '0', `term_taxonomy_id` bigint(20) unsigned NOT NULL default '0', `term_order` int(11) NOT NULL default '0', PRIMARY KEY (`object_id`,`term_taxonomy_id`), KEY `term_taxonomy_id` (`term_taxonomy_id`) the table I need to insert into is as follows: `wp_postmeta` ( `meta_id` bigint(20) unsigned NOT NULL auto_increment, `post_id` bigint(20) unsigned NOT NULL default '0', `meta_key` varchar(255) default NULL, `meta_value` longtext, PRIMARY KEY (`meta_id`), KEY `post_id` (`post_id`), KEY `meta_key` (`meta_key`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=22446 ; As noted above I want to query wp_term_relationships for all the records (object_id's) that have a "term_taxonomy_id" = 104 then Insert into wp_postmeta a post_id that matches the object_id and a meta_key that = "amprotect_amproducts" and a meta_value that = "a:6:{i:13;s:1:"1";i:6;s:1:"1";i:14;s:1:"1";i:7;s:1:"1";i:8;s:1:"1";i:1;s:1:"1";}" Any Ideas who to do this?? I was thinking INSTER INTO wp_postmeta ('object_id', 'amprotect_amproducts','')SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id = 104 Thanks, Link to comment https://forums.phpfreaks.com/topic/180200-insert-select-query-help/ Share on other sites More sharing options...
fenway Posted November 14, 2009 Share Posted November 14, 2009 I don't follow. Link to comment https://forums.phpfreaks.com/topic/180200-insert-select-query-help/#findComment-957448 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.