我现在有A,B,C 三张表 A:A_ID ,a_int01;  B:B_id,re_id    C: c_id,c_img01  其中c表是b表的附属表b_ID=c_id 对应 ,B 表的re_id=a_id  对应  那我现在想统计出 c表中c_img01的个数放在A表的a_int01 中  具体 怎么写 谢谢啊

解决方案 »

  1.   

    --试下
    insert into a(a_int01) select c_img01 from (select c_id,count(1) as c_img01 from b group by c_id)t
      

  2.   

    delete from A
    insert into A
    Select B.Re_ID,COUNT(distinct c_img01) num
    from B inner join C on B.b_ID=C.c_id 
      

  3.   

    update A
    set a_iint01 = (select count(1) from b,c where c_id = b_id and a.a_id = re_id)
      

  4.   

    少了group by re_ID
    delete from A
    insert into A
    Select B.Re_ID,COUNT(distinct c_img01) num
    from B inner join C on B.b_ID=C.c_id 
    Group by B.Re_ID
      

  5.   

    insert into A
    select B.re_id,count(*)
    from B,C where B.b_ID=C.c_id
    group by B.re_id
      

  6.   

    update a set
    a_int01=(select count(1) from b,c where b_ID=c_id  and re_id=a_id   )