update score
set score.stuno=
(
select student.stuno
from student
where student.name=score.name
)

解决方案 »

  1.   

    试试update a set a.stuno=b.stuno from score a,student b where a.name not in (select name,count(*) from score where having count(*)>1)
      

  2.   


    to  liupingsk(往事随风.......) :重名的怎么办?to  skyboy0720(飞) ( ) :比如说student表中有两个zhangto lidengdeng(lidengdeng) ( ) :数据量只有几千条to lzymagi(lzy_xy) :马上试试看
      

  3.   

    to lzymagi(lzy_xy) : select name,count(*) from score where having count(*)>1这个出错,不能这样查
      

  4.   

    问题解决,多谢多谢!!!UPDATE _cou
    SET id =
              (SELECT id
             FROM _stu
             WHERE _stu.name = _cou.name)
    WHERE ((SELECT COUNT(*)
              FROM _stu
              WHERE _stu.name = _cou.name) = 1)
      

  5.   

    楼主,不好意思。我没加group by .不过你能想到的吧!呵呵