首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

遇到个麻烦有关问题了,大家帮帮偶

2012-03-04 
遇到个麻烦问题了,大家帮帮偶有两张月份表tab200702(str1char(10),str2char(10),...str15char(10),DATEcha

遇到个麻烦问题了,大家帮帮偶
有两张月份表
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就不會報錯

热点排行