COUNT(*) from multiple tables in MySQL

前端 未结 5 1167
旧时难觅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

    Try changing to:

    SELECT 
        COUNT(table1.*) as t1,
        COUNT(table2.*) as t2,
        COUNT(table3.*) as t3 
    FROM table1 
        LEFT JOIN tabel2 ON condition
        LEFT JOIN tabel3 ON condition
    

提交回复
热议问题