有cy表如下:
编号  总分 名次
001   580  
004     580   
002     578    
003     578    
005     578    
006     560    
想用程序将该表更新为:
编号  总分 名次
001   580  1
004     580    1
002     578    3
003     578    3
005     578    3
006     560    6
用的程序如下:(但是调试不能通过)
adoquery5.Close;
adoquery5.SQL.Clear;
adoquery5.SQL.Add('Update cy Set a.名次=(Select count(*)+1 from cy as a Where b.总分>a.总分)From cy as b');
adoquery5.ExecSQL;
不知该sql语句错在哪里,怎么改?

解决方案 »

  1.   

    adoquery5.Close;
    adoquery5.SQL.Clear;
    adoquery5.SQL.Add('Update cy Set a.名次=(Select count(*)+1 from cy as a Where b.总分>a.总分)From cy as b');
    adoquery5.ExecSQL;//改成adoquery5.open
      

  2.   

    'Update cy Set 名次=(Select count(*)+1 from cy as a Where b.总分>a.总分)From cy as b'
    把a.名次改为名次
      

  3.   

    这样也行
    'Update cy as c Set c.名次=(Select count(*)+1 from cy as a Where b.总分>a.总分)From cy as b'
      

  4.   

    如下:
    adoquery5.Close;
    adoquery5.SQL.Clear;
    adoquery5.SQL.Add('Update cy Set a.名次=(Select count(*)+1 from cy a Where b.总分>a.总分)From cy  b');
    adoquery5.ExecSQL;
      

  5.   

    以上几个都不行呀?
    我是用这句话来操作一个access2000的cjgl.mdb这么一个数据库的
    不知道要在哪里改一下?