Reputation: 145
i want count(*)
from two different tables and a value from third table
like this:
table A: select count(*) from TABLE_A where grp_id = 1
table B: select count(*) from TABLE_B where grp_id = 1
table C: select totalcount from TABLE_C where grp_id = 1 and AND UserID = 1
so , i framed this query:
select ifnull((select count(*) from TABLE_A where grp_id = 1),0) + ifnull((select count(*) from TABLE_B where grp_id = 1),0)
will it be efficient way to do?
Upvotes: 0
Views: 264
Reputation: 103467
To my knowledge, that's totally fine.
The subqueries won't add any appreciable overhead.
Upvotes: 1
Reputation: 27313
Ramesh,
I think that would be efficient but why don't you do that on server side ? I think it would be more flexible then writing this SQL query.
Upvotes: 0