table1                                          table2
tel            countyId  operId                 id   operId
13705720001    5720                             1     867
13705720002    5725                             2     869
13705720003    5725                             3     868
13705720004    5720                             4     850
13705720005    5725                             5     849
13705720006    5721                             6     851
13705720007    5725                             7     848
..........     ....        将table1中的countyId为5725的数据平均分配给 table2中的operId
也就是说:如果table1中有28个号码countyId为5725的,那么平均每4(28/7)个号码后面的operId字段中填写一个operId(table2中),是不是写一个存储过程就可以解决的。

解决方案 »

  1.   

    上面的表1,表2看不清楚,重写
    table1                   
    tel         countyId  operId   
    13705720001  5720    
    13705720002  5725 
    13705720003  5725 
    13705720004  5720 
    13705720005  5725 
    13705720006  5721 
    13705720007  5725 
    .......... .... 
    table2
    id      operId
    1 867
    2 869
    3 868
    4 850
    5 849
    6 851
    7 848
      

  2.   

    table1的operid是什么值,将operid的值求和分配给table2吗?
    如果随机分配,如果table1有27条记录,或者table1记录数小于7,如何分配?