可否用一条sql实现同时返回几个表的记录个数比如表A,表Bselect count(*) from A
select count(*) from B怎样合在一起显示?

解决方案 »

  1.   

    select (select count(*) from A)+(select count(*) from B)
      

  2.   

    select count(*) from A
    union all
    select count(*) from B
      

  3.   

    select count(*) from A
    UNION ALL
    select count(*) from B
      

  4.   

    SELECT *
    FROM (SELECT 'A' AS tbname,COUNT(*) AS rowcnt FROM A) AS A,
       (SELECT 'B' AS tbname,COUNT(*) AS rowcnt FROM B) AS B
      

  5.   

    UNION ALL
    UNION ALL
    UNION ALL
    UNION ALL