日期:2014-05-18  浏览次数:20449 次

遇到个麻烦问题了,大家帮帮偶
有两张月份表
tab200702(str1   char(10),str2   char(10),...str15   char(10),DATE   char(10)),
tab200703(str1   char(10),str2   char(10),...str15   char(10),DATE   char(10)),字段是一样的,一共16个字段   ,根据选择条件去查询,如果选的是单个的月份就好办,可是如果夸月份怎么办呀?比如说查询条件是大于20070228,小于20070302。
注:DATE里   存的就是时间,格式为YYYYMMDD(如20070228)

------解决方案--------------------
select * from table200702 where date> '20070228 '
union
select * from table200703 where date < '20070302 '
------解决方案--------------------
between ...and
------解决方案--------------------
select * from table200702 where date> '20070228 '
union all
select * from table200703 where date < '20070302 '

------解决方案--------------------
haww1218() ( ) 信誉:100 Blog 2007-3-12 17:31:55 得分: 0



石头兄,您的方法好像有点问题: 不能以 DISTINCT 方式选择 text、ntext 或 image 数据类型。



----------

可以這樣

select * from table200702 where date> '20070228 '
union all
select * from table200703 where date < '20070302 '

用union all就不會報錯