Reputation: 83
need to fetch id, name, address details of a man from one table and and number of properties from another table belonging to him
we tried this way
select person.* count(property.id) from person, property where person.id = property.id
Upvotes: 0
Views: 38
Reputation: 204766
This is how you should do it
select person.id, person.name, person.address,
count(property.id)
from person
left join property on person.id = property.id
group by id, name, address
Group by all fields that are not aggregated (counted). And then use the explicit join syntax. The other is just outdated since decades.
Upvotes: 1