sql 查询

[复制链接]
查看11 | 回复2 | 2009-3-24 09:40:27 | 显示全部楼层 |阅读模式
例如 我想提取‘2009-03-02’ 和‘2009-03-05’ 两天的数据
where date='2009-03-02' 后面无论用 and 或者or 连接都不行应该怎么写
才可以同时显示出2天的数据
谢谢1 l
忘记说了 我的日期是用 substring (convert (varchar(10) ,date,120),1,10)这么写的 结果发现
where substring (convert (varchar(10) ,date,120),1,10) in ('2009-03-02','2009-03-05') 只能显示
'2009-03-05' 的数据 '2009-03-02' 还是不显示何解?

回复

使用道具 举报

千问 | 2009-3-24 09:40:27 | 显示全部楼层
我没有环境,没有测试,不知这样行不行,你看下select ...... from ......where substring (convert (varchar(10) ,date,120),1,10) ='2009-03-02'unionselect ...... from ......where substring (convert (varchar(10) ,date,120),1,10) ='2009-03-05'...
回复

使用道具 举报

千问 | 2009-3-24 09:40:27 | 显示全部楼层
select * from tablename where date in('2009-03-02','2009-03-05')...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行