我有10个表,分别代表十个仓库的具体事物,但是10个表是字段相同的,我想用union 将10个表联合起来,但是不知道可以在联合后加where条件么?我试了加where条件后查询的结果是不正确的,这是为什么呢?

解决方案 »

  1.   

    每个连接加各自的where条件select a,b,c from ddd where ....
    union
    select a,b,c from ddd where ....
    union
    select a,b,c from ddd where ....
      

  2.   

    select a, b, c from ddd
    union 
    select a, b, c from dddwhere ...我想把连个表连接后做where筛选,但是结果怎么不正确呢?
      

  3.   

    " select a, b, c from ddd 
    union 
    select a, b, c from ddd "
    这样的结果和" select a, b, c from ddd " 是一样的 
      

  4.   

    select a,b,c
    from 
    (select a, b, c from dd 
    union 
    select a, b, c from ddd ) twhere ... 这样应该可以