I need to take total count of files from category + sub category + subsub category
For that I write this kind of a query using my views.
select ((select count(*) from view_category where 1=1)+ (select count(*) from view sub category where 1=1) + (select count(*) from view subsub category where 1=1)) as cnt
Its returning count value. But I want to know any other better method is available to get the same result.
I tried this way but its not working (How to SUM() multiple subquery rows in MySQL?)
select sum(int_val) from((select count(*) from view_category where 1=1) as int_val union (select count(*) from view sub category where 1=1) as int_val union (select count(*) from view subsub category where 1=1) as int_val ).
This is working for me