update table1 set name=(select  from table2 where table1.id=table2.id) 
where exists (select 1 from table2 where table1.id=table2.id);

解决方案 »

  1.   


         to :ORARichard(没钱的日子好难过啊)       非常感谢你的答复,果然高人.但是我有一点不明白的是:
           select 1 from table2 where table1.id=table2.id  这句是个什么用法呀?
           不是很理解,为什么select 后边是个1,如果改为2又代表什么呢?
          谢谢:)
      

  2.   

    1是逻辑值,其实只判断真假值,一般你写成exists (select * from table2 where table1.id=table2.id);就可以了
      

  3.   

    可以找一写资料看看,就是关于select语句的,安装一个第三方的数据库软件,可以方便地调用oracle数据库,可以对各种select语句进行测试,多用几次就知道是什么意思了。
      

  4.   


             哦,谢谢楼上的,偶明白了,select测试到是可以,问题是根本想不出来那种写法,自然测试就谈不上的啦.不过我相信过一阶段我就不会再问这么低级的问题啦.
              哈哈,天天快乐:)
      

  5.   

    也可以这样
    update (select ID,Mark from table1) a,(select ID,Name from table1) b
    set a.Mark=b.Name
    where a.ID=b.ID
      

  6.   


       to :luhualing(卢华令) 
        你的那种写法我试过了.报错哦.说SQL语句错误.