2,722
社区成员
发帖
与我相关
我的任务
分享
将
Update 原表名 Set subid=(Select Count(*)+1 From 原表名 B Where b.objectid=原表名.objectid And B.subid<原表名.subid)
改为
Select a.objectid,a.c_name,Count(a.objectid) as subid From 原表名 a Left Join 原表名 b On a.objectid=b.objectid And a.subid<=b.subid Group By a.objectid,a.c_name
这样VFP9.0以下也可以用了。
--生成测试数据,假设subid为数值型
Create Cursor 原表名 (objectid c(10),c_name c(10),subid I)
Insert Into 原表名 Values ('001','sdfsdf',0)
Insert Into 原表名 Values ('001','45sfd',0)
Insert Into 原表名 Values ('002','sdfsdf',0)
Insert Into 原表名 Values ('003','ssdfsdf',0)
Insert Into 原表名 Values ('002','sdfsfd54',0)
--生成测试数据结束
Update 原表名 Set subid=Recno()
Update 原表名 Set subid=(Select Count(*)+1 From 原表名 B Where b.objectid=原表名.objectid And B.subid<原表名.subid)
Browse &&看一下结果吧