Update TableA set ColumnN=(select Count(*) from TableB) 
where ....  --條件進行記錄定位 

解决方案 »

  1.   

    写存储过程可以,但是在存储过程中的Select 语句
    也要写23*23个哦select 什么什么 from (表名好像不能是变量哦)好像还不如用程序控制的好
      

  2.   

    能不能具体一点?
    怎么插入?
    我先建了一张空表。
         25岁  26岁  30岁  32岁  33岁  35岁。
    木工
    泥工
    电工
    水管工
    教师



    比如说第一行第一格:
    select count(*) from 员工表 where birth<1977 and 职业=电工
    请问怎么把得到的count(*)赋给第一行第一格?
    谢谢大家了
      

  3.   

    不知道你的是什么库,我在oracle中用循环就实现;
      sqlserver不知道有没有
      oracle中:
       cursor mycursor is select  职业 from 职业表;//cursor 存储职业
       cursor mycursor2 is select 年龄 from 年龄表;
       ZY:varchar(10);
       age:number(3,0)
    begin
      open mycure;
      fetch mycur into zy ;
      while mycur1%found loop
         fetch mycur into zy ;
         open mycure2 ;
         fetch mycur2 into age;
         while mycur2%found loop
           fetch mycur2 into age;
              // 执行你的代码
           end loop;
         close mycure2;
       end loop;
       close mycure1;
    end;