一个表格tableA  
id B_id 一个表格tableB
id C_id一个表格tableC
id row2
tableA.B_id 对应tableB.id 
tableB.C_id 对应tabelC.id请问一下 我怎么去查找出这样一个结果:
每个tableC.id 对应的count(*) 在tableA中的记录数两个表格的话可以group by
三个表格的话不知道如何操作啦~~~~语句如下:select count(*) from tableA where tableA.B_id in(select tableB.id from tableB where tableB.C_id=***)
这个语句是一个个tableC.id 去统计的,当然不可能这样啦~~谢谢!!

解决方案 »

  1.   

    --如果是一对一关系
    Select Count(1) from tableA a,tableB b,tableC c
     where a.B_id=b.id and b.C_id=c.id
      

  2.   

    其实 我想要的结果是这样的
    tableC的第二列  count的数目(tableA)能不能这样的呢???
      

  3.   

    select count(*) 
    from tableA A,tableB B,tableC C 
    where A.B_id=B.id and B.C_id=C.id
    group by C.id
      

  4.   

    select a.id,count(*) 
    from tableA A,tableB B,tableC C 
    where A.B_id=B.id and B.C_id=C.id
    group by a.id
      

  5.   

    lexchi() ( ) 信誉:100  2007-09-10 19:41:16  得分: 0  
     
     
       select count(*) 
    from tableA A,tableB B,tableC C 
    where A.B_id=B.id and B.C_id=C.id
    group by C.id
      
     
    好像不行吧~~
      

  6.   

    select c.id,count(*)
      from tableA a,tableB b,tableC c
     where a.B_id = b.id
       and b.C_id = c.id
     group by c.id;