update c set useid=(select max(a.useid) from a,b where a.id1=b.id1 and a.id2=b.id2 and
a.id3=b.id3 and b.bid=c.bid)
where exists(select 1 from a,b where a.id1=b.id1 and a.id2=b.id2 and
a.id3=b.id3 and b.bid=c.bid);

解决方案 »

  1.   

    谢谢楼上bzszp(SongZip)朋友,不过我有点问题想问问,你的语句中的为什么要max(a.useid)
    然后,下面的select 1有什么意义吗?小弟不才,这里有点看不懂。谢谢指导!1
      

  2.   

    没有什么意义!
    你也可以写成select a.id1,b.id1 from a,b
    关键在exists
      

  3.   

    select 1没有意义,只是用来判断exists是否有效;max(a.useid)主要是当a表有重复记录时就取ID最大的那个,比如A表如下
    a表
    useid  id1 id2 id3
    1      001 002 003
    2      004 005 006 
    3      007 008 009
    4      007 008 009