select *From t_ecp_data t where t.enble='Y'
union all
select *from t_entity_path_indext_ecp_data t_entity_path_index表结构不一样

解决方案 »

  1.   

    表结构不一样的话,不能用这种union all的语句。
    你想把两张表的数据都列出来?还是想干嘛?
      

  2.   


    结构不一样,需要指明结果中的列,两个表的结果列相同即可,如:
    select A,B,C From t_ecp_data t where t.enble='Y'
    union all
    select A,B,C from t_entity_path_index
      

  3.   

    那就先分开列出,然后再excel里粘到一块
      

  4.   

    只要列的个数相同,并且存储的数据意义上是相同的,可以用相同的别名,进行union all.
    如果列的个数不同,但可以只查询指定的列,也是可以的。
    举例:
    Products(product_id, product_type_id, name, description, price)
    MoreProducts(prd_id, prd_type_id, name, available)select product_id as id, product_type_id as ptid, name
    from products
    union all
    select prd_id as id, prd_type_id as ptid, name
    from MoreProducts;