根据日期每天生成一个表,命名格式 Local_日期,例如Local_20120224,Local_20120225表的格式是一样的,有字段类型为text的字段现在要从这些表中查询所有数据应该如何查询呢 ?我尝试了一下select * from Local_20120224,Local_20120225 where SourceID = 'src:10104' and pType = 'Central'或者select * from Local_20120224 where SourceID = 'src:10104' and pType = 'Central' union 
select * from Local_20120225 where SourceID = 'src:10104' and pType = 'Central' 都不行

解决方案 »

  1.   

    select * from (
    select * from Local_20120224  union 
    select * from Local_20120225
    ) a where a.SourceID = 'src:10104' and a.pType = 'Central'
      

  2.   

    select * from Local_20120224 where SourceID = 'src:10104' and pType = 'Central' union 
    select * from Local_20120225 where SourceID = 'src:10104' and pType = 'Central'你的这句也是可以的。 
      

  3.   


    这句不行说是有text类型的字段时union 好像就不能用了
      

  4.   


    这句在运行的时候提示 不能以 DISTINCT 方式选择 text、ntext 或 image 数据类型。
      

  5.   

    我给你转到 SQL Server 版吧。
      

  6.   

    y
    用union all试试??