select count(id)as ptotal,c17,c18 from eceye_contents where c17 <>'' group by c17,c18;
select count(id)as text_total,c17,c18 from eceye_contents where  c17 <>''and ar_type='text' group by c17,c18;

解决方案 »

  1.   

    select count(id)as ptotal,c17,c18 from eceye_contents where c17 <>'' group by c17,c18
    union all
    select count(id)as text_total,c17,c18 from eceye_contents where  c17 <>''and ar_type='text' group by c17,c18;
      

  2.   

    用子查询
    select  A.ptotal,B.text_total,A.c17 as c17A,B.c17 as c17B,A.c18 as c18A,B.c18 as c18B
    from (
              select count(id) as ptotal,c17,c18 from eceye_contents where c17 <>'' group by c17,c18) as A,
    (select count(id) as text_total,c17,c18 from eceye_contents where  c17 <>''and ar_type='text' group by c17,c18) AS B
    如果用union的话也可以,就是把count(id) 别名为统一名称
    select count(id)as ptotal,c17,c18 from eceye_contents where c17 <>'' group by c17,c18
    union all
    select count(id)as ptotal,c17,c18 from eceye_contents where  c17 <>''and ar_type='text' group by c17,c18
      

  3.   

    to  dada20042030:
     但是查询的结果似乎不是我想要的?
    结果是多条union后和查询一条没什么区别