比如有两个表fy ,xh 他们是通过xhid 关联
我使用下面的语句
select fy.*,xh.* from fy,xh where fy.xhid=xh.xhid
查询了有 N 条记录 现在我用什么语句 来对他们的 N 条记录汇总???
如果是一个表 如 fy
我可以使用
select count(*) from fy 得到fy 的总条数
高手教我!!!

解决方案 »

  1.   

    select count(*) from fy,xh where fy.xhid=xh.xhid
    这样不可以么
      

  2.   

    select count(fy.FieldName) from fy,xh where fy.xhid=xh.xhid
    其中FieldName为fy的一个字段
      

  3.   

    create table fy(xhid int,a varchar(100));
    create table xh(xhid int,b varchar(100));insert into fy select 1,'a1'
    union
    select 2,'a2'insert into xh select 1,'b1'
    union
    select 2,'b2'
    union
    select 3,'b3'select * from fy,xh where fy.xhid=xh.xhid
    ----------------------------------------------------
    1 a1 1 b1
    2 a2 2 b2select count(*) from fy,xh where fy.xhid=xh.xhid----------------------------------------------------
    2