between 2004-10-11 and 2004-12-22

解决方案 »

  1.   

    select * from 
      (select * from [200410]
       union all
       select * from [200411]
       union all
       select * from [200412])
    where 
       采样时间 between cast('2004-10-11' as datetime) and cast('2004-12-22' as datetime)
      

  2.   

    select a.* from 
      (select * from [200410]
       union all
       select * from [200411]
       union all
       select * from [200412]) a
    where 
       a.采样时间 between cast('2004-10-11' as datetime) and cast('2004-12-22' as datetime)
      

  3.   

    select * from [200409] where 采样时间 between '2004-10-11' and '2004-12-22'联合:
    select * from(
    select * from [200409] 
    union all
    select * from [200410] 
    union all
    select * from [200411] 
    union all
    select * from [200412]) a
    where 采样时间 between '2004-10-11' and '2004-12-22'删除重复就用: union
      

  4.   

    select * from t1
    where 采样时间 between 2004-10-11 and 2004-12-22
    union 
    select * from t2
    where 采样时间 between 2004-10-11 and 2004-12-22
    ...
      

  5.   

    --可以考虑使用视图
    create view vi_test
    as
    select * from [200409] 
    union all
    select * from [200410] 
    union all
    select * from [200411] 
    union all
    select * from [200412]go--then
    select * from vi_test where 条件
      

  6.   

    谢谢各位前辈,: chinaandys(努力混颗星,回家泡MM) 解释的内容对我很有用,谢谢!
    happydreamer(小黑) 、libin_ftsafe(子陌红尘) 你们都很棒!!!