日期:2014-05-17  浏览次数:20869 次

三个表怎么做关联?
条件:

表A的number=表B的number=表C的number

表A的time=表C的time=20120312

表A的level=2

我现在是这样写的:

SQL code

select 表C.Value from 表A,表B,表C where 表A.number=表B.number and 表B.number=表C.number and 表A.level = 2 and 表A.time=to_date('20120311','yyyy/mm/dd') and 表C.time=to_date('20120311','yyyy/mm/dd')



------解决方案--------------------
以表A为基础来关联
SQL code

select C.Value 
from A,B,C 
where A.number=B.number and 
      A.number=C.number and 
      A.level = 2 and 
      A.time=C.time and            
      A.time=to_date('20120311','yyyy/mm/dd')

------解决方案--------------------
SQL code

select C.Value 
from A,B,C 
where A.number=B.number and 
      A.number=C.number and 
      A.level = 2 and 
      A.time=C.time and            
      to_char(A.time,'yyyy/mm/dd')='20120311'