COUNT(*) from multiple tables in MySQL

前端 未结 5 1177
旧时难觅i
旧时难觅i 2020-11-30 03:50

How do I go about selecting COUNT(*)s from multiple tables in MySQL?

Such as:

SELECT COUNT(*) AS table1Count FROM table1 WHERE someCondition
JOIN?? 
         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-30 04:05

    You can do this with subqueries, e.g.:

    select (SELECT COUNT(*) FROM table1 WHERE someCondition) as table1Count, 
           (SELECT COUNT(*) FROM table2 WHERE someCondition) as table2Count 
    

提交回复
热议问题