日期:2014-05-16 浏览次数:20824 次
select a.name from A a,B b where a.name=b.name and to_char(a.date,'yyyymmdd') <= to_char(b.end_date,'yyyymmdd') and to_char(a.date,'yyyy-mm-dd')='2010-11-15'
select a.name from A a,B b where a.name=b.name and to_char(a.date,'yyyy-mm-dd')='2010-11-15'
------解决方案--------------------
你的语句相当于
select a.name from A a,B b where a.name=b.name
and to_char(b.end_date,'yyyy-mm-dd') = > '2010-11-15'
你看看这个有数据不,
------解决方案--------------------
--坑爹阿,咋不行了? with tab1 as ( select 'a' name, sysdate A_date from dual union all select 'b', sysdate + 1 from dual union all select 'c', sysdate + 2 from dual ), tab2 as ( select 'a' name, sysdate B_date from dual union all select 'b' , sysdate + 1 from dual union all select 'c', sysdate from dual ) --只用name关联,查询结果 select * from tab1, tab2 where tab1.name = tab2.name ------------------ a ********* b ********* c 省略行不行,还用写这些吗? --用name和日期两个条件查询结果 select * from tab1, tab2 where tab1.name = tab2.name and to_char(tab1.A_date, 'yyyymmdd') = to_char(tab2.B_date, 'yyyymmdd') --------------------- a ****** b 这个也省略行不行??阿?行不行 --用三个条件查询 select * from tab1, tab2 where tab1.name = tab2.name and to_char(tab1.A_date, 'yyyymmdd') = to_char(tab2.B_date, 'yyyymmdd') and to_char(tab1.A_date, 'yyyy-mm-dd') = '2011-09-20' -------------------- b *******(还是省略有木有) --ps:我擦,累死鸟!!全部都是一个一个字母敲上去的,真JB累阿!!!! --楼主哥们,你再好好看看你的表吧!
------解决方案--------------------
select a.name from A as a inner join B as b on b.name = a.name and b.end_date >= a.date where to_char(a.date,'yyyy-mm-dd')= '2010-11-15'