我有2张桌子。
表主题
topic_id |自动递增
topic_pid | int =>指向他的父母
topic_name |字符串
表事件
topic_id | int =>指向主题表
标题|字符串
我想获得向我展示每个主题的结果?每个主题及其子代有多少个事件?
例如
TOPIC TABLE
————————————-
topic_id | topic_pid | topic_name
1 0 product
2 1 downloadable
3 2 movie
EVENT TABLE
————————————-
topic_id | title
3 buy
3 like
2 like
我的理想答案:
name | event count product 3 downloadable 3 movie 2
因为电影是可下载的子级,而可下载的是产品的子级
我的主题孩子有孩子