SELECT country.title, COUNT(t2.id), COUNT(t3.id)
FROM country, city t2, city t3
WHERE country.id = t2.country_id
AND country.id = t3.country_id
GROUP BY t2.country_id, t3.country_id
ORDER BY country.id
Так не работает.
С одниим Join работает, если два уже нет.
Lets say you want to count how many customers, sales and suppliers/vendors some user in your system has, in a single query. A naive approach would be to do this: SELECT user_accounts.id, user_accounts.company_name, COUNT(DISTINCT suppliers.id) AS suppliers, COUNT(DISTINCT...