Reputation: 19882
I have two tables and i am trying to get count from both tables. Means count from first table then count from 2nd table and result should look like this.
Count(users.name) Count(users_types)
5 8
But my query brings this result
Count(users.name) Count(users_types)
8 8
Here is my query
select count(users.users),
count(users_types.users_types)
form users , users_types
How can i get correct result?
Upvotes: 1
Views: 149
Reputation: 19882
Use a sub query like this
select
count(users.users) Users,
(select
count(users_types.users_types)
from teams) UsersTypes
from users
Upvotes: 0
Reputation: 1704
select (select count(*) cnt1 from table1),
(select count(*) cnt2 from table2)
Upvotes: 1
Reputation: 100175
try:
select
(select count(users.users) from users),
(select count(users_types.users_types) form users_types)
Upvotes: 1