中间表中就2个idAID ,BID  ,然后我想向这张表里插入数据因为里面有数据了,  
AID  BID
1    2
2    3
如果原来里面就有两条数据而我插入第三条数据的时候,这两条数据也要一起传过来,应该怎么插入第三条数据

解决方案 »

  1.   


    --a为中间表,b为传入数据的表
    merge into tab1 a
    using tab2 b
    on (a.aid=b.aid and a.bid=b.bid)
    when not matched then
      insert values (b.aid,b.bid); 
      

  2.   

    merge into tab1 a
    using tab2 b
    on (a.aid=b.aid and a.bid=b.bid)
    when not matched then
      insert values (b.aid,b.bid); 
      

  3.   


    oracle 中可以这么写吗?
      

  4.   


    ORACLE中经典的MERGER用法,,自己百度看看
      

  5.   


    merge into tab1 a
    using tab2 b
    on (a.aid=b.aid and a.bid=b.bid)
    when not matched then
      insert values (b.aid,b.bid); 
      

  6.   

    merge ....
    但我确实是没看明白楼主啥意思?
      

  7.   


    明确点说, 原来数据库中有的数据,我在执行插入的时候,直接过滤掉  就比如说 
    表里已有的数据
    AID BID 
    1   2
    2   3
    而传回来的数据有
    AID BID
    1   2
    2   3
    3   4
    我只要把  AID 3  BID 4这条插入进去,前两条过滤不插入,这只是一个例子,传回来的值不可能就一条,很可能是多条