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(id) as tot_course from course_table`
Like this I have 12 tables.
Can i make it in single query. If i did? Process gets slow?
SELECT ( SELECT COUNT(*) FROM user_table ) AS tot_user, ( SELECT COUNT(*) FROM cat_table ) AS tot_cat, ( SELECT COUNT(*) FROM course_table ) AS tot_course
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With