表1    
id     
1       
5       
2       
d
3
表2
id1     id2         gz
3    20080711      2
5    20080711      1
1    20080011      3
我期望的是:    把ID2=20080711 带进去
id  gz
1    
5    1
2
d
3    2select biao1.id,gz from biao1,biao2 where biao2.id1(+)=biao1.id
这是现在用的语句 但是不能加 ID2=20080711 这个条件.  请问怎么写SQL可以带进这个条件呢
我想可以用临时表  然后 update id2!=20080711 就 =""  然后输出临时表的信息
 
  但是有没有用语句能写出来的方法?  请赐教...

解决方案 »

  1.   


    select biao1.id,biao2.gz from biao1 inner join biao2 on biao1.id=biao2.id 
    where biao2.ID2=20080711 
      

  2.   

    select biao1.id,id2 ,gz from biao1,biao2 where biao2.id1(+)=biao1.id  and biao2.id2='20080711'
      

  3.   

    select biao1.id,gz 
    from biao1,biao2 
    where biao2.id1(+)=biao1.id and bao2.id2='20080711';
    这样不行吗?
      

  4.   

    select biao1.id,gz from biao1,biao2 where biao2.id1(+)=biao1.id and biao2.id2=20080711--或者select biao1.id,gz from biao1,(select * from biao2 where biao2.id2=20080711)t2 where t2.id1(+)=biao1.id 
      

  5.   

    楼主要的可能是不要把biao2.id2=20080711这条件放在后面.
      

  6.   

    修改不用临时表update biao2
    set  id2=null where exits (select 1 from biao2 where id2<>20080711
      

  7.   

    楼主,这样可以吗:select biao1.id,decode(biao2.id2,'20080711',gz,null) as gz from biao1,biao2 where biao2.id1(+)=biao1.id
      

  8.   

    弱问一下:biao2.id1(+)=biao1.id   这里的那个(+) 是啥意思...
      

  9.   

    谢.
     就是要
    select biao1.id,gz from biao1,(select * from biao2 where biao2.id2=20080711)t2 where t2.id1(+)=biao1.id 
    这个效果