我有以下 mysql 数据库表:
cities
states
countries
和
members
samajs
(国际上的一群人)
我想为我的dashboard
页面创建一个查询,该查询将具有以下结果:
Country Members Samajs Total (table header)
Country1 7 5 16 (country row with total members, samajs and total count)
state1 5 2 7 (state row with total members, samajs and total count)
city1 3 1 4 (all cities in that state, city row with total members, samajs and total count)
city2 2 0 2
state2 2 1 3
Country2 3 2 5 (country row with total members, samajs and total count)
...and vice versa....
在这里,members
表将country_id, state_id and city_id
作为外键
samajs
表也将 country_id, state_id and city_id
作为外键
任何想法,相同的查询是什么?
谢谢 !!