我有3个表(ManyToMany(:
- 电影
- 移动
- 流派
我的表格结构:
电影:
- id
- 名称
流派:
- id
- 名称
移动:
- idMovie
- idGenre
电影通过moviegenre表(ManyToMany连接(与类型相连接。现在我想知道我有多少电影类型(例如"动作"(
Example result:<br/>
Action | 12<br/>
Horror | 9<br/>
Thriller| 3<br/>
...
你能帮我创建这个"简单"查询吗?(MySQL 5.5.13(
非常感谢!:D
SELECT G.name, count(MG.idMovie)
FROM MovieGenre MG
INNER JOIN Genre G on MG.idGenre = G.ID
GROUP BY G.name