2个数据库上的UNION需要UPDATE才能工作

时间:2017-02-27 09:28:31

标签: mysql

我创建了一个效果很好的UNION视图。但我需要在此视图上更新并获得更新错误。如何更改此视图语法以便能够对这些记录执行UPDATE?

这是我的查询;

SELECT 
    `DB1`.`wp_posts`.`ID` AS `ID`,
    `DB1`.`wp_posts`.`post_date` AS `post_date`,
    `DB1`.`wp_postmeta`.`meta_key` AS `meta_key`,
    `DB1`.`wp_postmeta`.`meta_value` AS `meta_value`,
    `DB1`.`wp_postmeta`.`processed` AS `imported`,
    `DB1`.`wp_posts`.`processed` AS `postprocessed`
FROM (`DB1`.`wp_postmeta` JOIN `DB1`.`wp_posts` ON ((`DB1`.`wp_postmeta`.`post_id` = `DB1`.`wp_posts`.`ID`))) 
WHERE ((`DB1`.`wp_posts`.`post_type` = 'flamingo_inbound') AND (`DB1`.`wp_posts`.`processed` = 0)) 

UNION 

SELECT 
    `DB2`.`wp_posts`.`ID` AS `ID`,
    `DB2`.`wp_posts`.`post_date` AS `post_date`,
    `DB2`.`wp_postmeta`.`meta_key` AS `meta_key`,
    `DB2`.`wp_postmeta`.`meta_value` AS `meta_value`,
    `DB2`.`wp_postmeta`.`processed` AS `imported`,
    `DB2`.`wp_posts`.`processed` AS `postprocessed` 
FROM (`DB2`.`wp_postmeta` join `DB2`.`wp_posts` ON ((`DB2`.`wp_postmeta`.`post_id` = `DB2`.`wp_posts`.`ID`))) 
WHERE ((`DB2`.`wp_posts`.`post_type` = 'flamingo_inbound') AND (`DB2`.`wp_posts`.`processed` = 0))

0 个答案:

没有答案