|
本帖最后由 liyihongcug 于 2011-9-21 20:30 编辑
http://zh-cn.w3support.net/index.php?db=so&id=514817这样做 是可以的
CREATE VIEW vw_product_services AS
SELECT DISTINCT products.pid AS id,
products.pname AS name,
products.p_desc AS description,
products.p_loc AS location,
products.p_uid AS userid,
products.isaproduct AS whatisit
FROM products
UNION
SELECT DISTINCT services.s_id AS id,
services.s_name AS name,
services.s_desc AS description,
services.s_uid AS userid,
services.s_location AS location,
services.isaservice AS whatisit
FROM services
但是如果一个表 是fedarated 引擎表 将会错误(含有fedarated 引擎的表不能union)
普通表 是可以做view
对于实际应用的fedarated连接多台机器的情况
ERROR 1271 : Illegal mix of collations for operation 'UNION'
目前可用的方法是 select * from customer join fed_number on customer.number_id=fed_number.id
实际使用要用到3个以上的视图或表来处理不同源头表的数据同步
他不能用union
但是可以用 not in
2个not in 和一个inner join基本可以把所有不同的情况都知道。
用 left join 或者right join http://topic.csdn.net/u/20110804 ... c-99dce10618a2.html
是网络原因 。
经过测试 本地2个federeated 表 (他们分别对应远程2台机器的表)
总共是3台机器
最后发现是可以做union的
前面测试错误原因在于 网络单向不通
[ 本帖最后由 liyihongcug 于 2011-9-14 16:25 编辑 ] |
|