1. 程式人生 > >如何用一個SQL語句查詢多個表的記錄數

如何用一個SQL語句查詢多個表的記錄數

轉自:http://blog.csdn.net/keketrtr/article/details/5894067

sql語句如下:

select t1.num1,t2.num2 from 
  (select count(*) num1 from table1) t1,
  (select count(*) num2 from table2) t2

如果要顯示這兩張表中記錄數的總和就是

select t1.num1+t2.num2 from 
  (select count(*) num1 from table1) t1,
  (select count(*) num2 from table2) t2