between and

TechieFeng 2010-01-19 08:13:18
select * from a
where a1 between (select b1 from b where to_char(a_date, 'yyyymm') like '%200901%')
and (select b2 from b where to_char(a_date, 'yyyymm') like '%200901%' )这样写可以吗?谢谢!
...全文
93 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
simonyo 2010-01-21
  • 打赏
  • 举报
回复
select * from a
where a1 between
(select min(b1) from b where to_char(a_date, 'yyyymm') like '%200901%')
and
(select max(b2) from b where to_char(a_date, 'yyyymm') like '%200901%' )

--不知你是不是想要这种效果
simonyo 2010-01-21
  • 打赏
  • 举报
回复
3楼的方法很巧妙
tjuxl123 2010-01-21
  • 打赏
  • 举报
回复
select * from a
where exists (select 1 from b where a_date>=date'2009-1-1'
and a_date <date'2010-1-1'
and a.a1 between b1 and b2) 这个就很好
crazylaa 2010-01-19
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 techiefeng 的回复:]
子查询里是多条记录,那怎么解决?
[/Quote]
看wildwave那条满足你的需求
TechieFeng 2010-01-19
  • 打赏
  • 举报
回复
子查询里是多条记录,那怎么解决?
zhangwonderful 2010-01-19
  • 打赏
  • 举报
回复
同意3楼的方法
小灰狼W 2010-01-19
  • 打赏
  • 举报
回复
select * from a
where exists (select 1 from b where a_date>=date'2009-1-1'
and a_date<date'2010-1-1'
and a.a1 between b1 and b2)
Dave 2010-01-19
  • 打赏
  • 举报
回复

最简单的方法就是把SQL运行一下,一下就看出来.




------------------------------------------------------------------------------
Blog: http://blog.csdn.net/tianlesoftware
网上资源: http://tianlesoftware.download.csdn.net
相关视频:http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx
Q Q 群:62697716
crazylaa 2010-01-19
  • 打赏
  • 举报
回复
如果子查询存在多条记录,则不可以。

17,089

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧