1.SELECT count(*) 台账,et.cname 市场 FROM customer,et,stock where et.fid = customer.ascname and stock.bid = customer.azid  group by et.cname 
台账     市场
16 海滨市场2.SELECT count(*) 商贩 FROM customer,et where et.fid = customer.ascname
商贩
139问如何合并成
台账  市场        商贩
16    海滨市场    139

解决方案 »

  1.   

    SELECT count(*) 台账,et.cname 市场 FROM customer,et,stock where et.fid = customer.ascname and stock.bid = customer.azid group by et.cname  
    union
    SELECT '','',count(*) 商贩 FROM customer,et where et.fid = customer.ascname试试!
      

  2.   

    也可能是:
    SELECT count(*) 台账,et.cname 市场 FROM customer,et,stock where et.fid = customer.ascname and stock.bid = customer.azid group by et.cname   
    union
    SELECT 0,0,count(*) 商贩 FROM customer,et where et.fid = customer.ascname试试
      

  3.   

    哦应该是这样:
    SELECT count(*) 台账,et.cname 市场,'' FROM customer,et,stock where et.fid = customer.ascname and stock.bid = customer.azid group by et.cname   
    union
    SELECT '','',count(*) 商贩 FROM customer,et where et.fid = customer.ascname
      

  4.   

    用左外连接:
    select a.*,b.* from
    (SELECT count(*) 台账,et.cname 市场,''  FROM customer,et,stock where et.fid = customer.ascname and stock.bid = customer.azid group by et.cname)  as a
    left join (SELECT et.cname,count(*) 商贩 FROM customer,et where et.fid = customer.ascname) as b
    ON a.市场=b.username 
      

  5.   

    SELECT count(*) 台账,et.cname 市场,(select count(*) 商贩 FROM customer a where et.fid = a.ascname) FROM customer,et,stock where et.fid = customer.ascname and stock.bid = customer.azid group by et.cname  
    合并就是
    SELECT count(*) 台账,et.cname 市场,0 FROM customer,et,stock where et.fid = customer.ascname and stock.bid = customer.azid group by et.cname   
    union
    SELECT '','',count(*) 商贩 FROM customer,et where et.fid = customer.ascname
      

  6.   

    看到5楼 自己琢磨下 得出
    select a.*,b.* from 
    (SELECT count(*) 台账,et.cname 市场 FROM customer,et,stock where et.fid = customer.ascname and stock.bid = customer.azid group by et.cname) as a 
    left join 
    (SELECT et.cname 市场,count(*) 商贩 FROM customer,et where et.fid = customer.ascname group by et.cname) as b 
    ON a.市场=b.市场  
    虽然多楼一个市场 但都可以接受...  
      

  7.   

    SELECT count(*) 台账,
    t2.cname 市场, 
    商贩=(SELECT count(*)  FROM customer a,et b where a.fid = b.ascname and a.fid=t1.fid and b.ascname=t2.ascname)
    FROM 
    customer t1 ,
    et t2,
    stock  t3
    where
    t2.fid = t1.ascname 
    and t3.bid = t1.azid 
    group by t2.cname