代码
CREATE OR REPLACE VIEW `posts` AS
(SELECT '11' AS blog_id
, 'blog1.domain.net' AS domain
, '/' AS path
, posts11.*
FROM wp_11_posts posts11
WHERE posts11.post_type = 'post'
AND posts11.post_status = 'publish')
UNION
(SELECT '20' AS blog_id
, 'blog2.domain.net' AS domain
, '/' AS path
, posts20.*
FROM wp_20_posts posts20
WHERE posts20.post_type = 'post'
AND posts20.post_status = 'publish')
没有错误,这个
CREATE OR REPLACE VIEW `posts` AS
(SELECT '11' AS blog_id
, 'blog1.domain.net' AS domain
, '/' AS path, posts11.*
FROM wp_11_posts posts11
WHERE posts11.post_type = 'post'
AND posts11.post_status = 'publish')
UNION
(SELECT '2' AS blog_id
, 'blog2.domain.net' AS domain
, '/' AS path, posts2.*
FROM wp_2_posts posts2
WHERE posts2.post_type = 'post'
AND posts2.post_status = 'publish')
给我错误
#1222 - The used SELECT statements have a different number of columns
区别仅在于表的id,并且所有表或行都退出, 谢谢你的帮助