Multiple select statements in Single query

后端 未结 6 780
青春惊慌失措
青春惊慌失措 2020-11-28 02:58

I am generating a report in php (mysql),

ex:

`select count(id) as tot_user from user_table
 select count(id) as tot_cat from cat_table
 select count(         


        
6条回答
  •  误落风尘
    2020-11-28 03:10

    If you use MyISAM tables, the fastest way is querying directly the stats:

    select table_name, table_rows 
         from information_schema.tables 
    where 
         table_schema='databasename' and 
         table_name in ('user_table','cat_table','course_table')
    

    If you have InnoDB you have to query with count() as the reported value in information_schema.tables is wrong.

提交回复
热议问题