Hi I need a query like this
select count(id) from employee where.. => gives count1=10
select count(id) from emplyer where.. => gives count2=5
select count(id) from users where.. => gives count3=20
I can add these result like this
count = count1+count2+count3;
But I want to know whether there is any option get count using a single query instead of add these result separatly. Also I want to know which one is the best way in case of application perfomance.
You can do
There will hardly be a performance difference – adding three integers is neither a challenge for the MySql nor for the php engine.