# Posts under topics with nested topic\_id unincluded

**URL:** <https://meta.discourse.org/t/posts-under-topics-with-nested-topic-id-unincluded/90702>\
**Category:** Data & reporting\
**Tags:** sql-query\
**Created:** [25 juni 2018 om 12:54 UTC](https://meta.discourse.org/t/posts-under-topics-with-nested-topic-id-unincluded/90702 "2018-06-25T12:54:35Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![uptownyumiko](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/uptownyumiko/32/119808_2.png) [@uptownyumiko](https://meta.discourse.org/u/uptownyumiko)\
**Post date:** [25 juni 2018 om 12:54 UTC](https://meta.discourse.org/t/posts-under-topics-with-nested-topic-id-unincluded/90702/1 "2018-06-25T12:54:35Z")

</div>

Hi,

I am trying to export the list of Like and Liked interaction by topics remixing the sample code, and realized that the topics I was particularly trying to look at seemed to not be included in the list. The code I tried was:

```
WITH pairs AS (
SELECT p.user_id liked, pa.user_id liker, p.topic_id topic
FROM post_actions pa
LEFT JOIN posts p ON p.id = pa.post_id
WHERE post_action_type_id = 2 --2 means liked
)
SELECT liker liker_user_id, liked liked_user_id, topic topic_id, count(*)
FROM pairs
GROUP BY liked, liker, topic_id
ORDER BY topic_id DESC

```

I’ve noticed that the difference between the topics I am looking for and the topics I get is that the former’s topic\_id is nested: example [one](http://lcl-discuss.media.mit.edu/t/round-1-introduce-yourself/54/1292) and [two](http://lcl-discuss.media.mit.edu/t/week-4-activity-visit-a-learning-space/447/125). These topics with nested topic\_id were created last year, reorganized as a new category early this year, because we needed to create topics with the same titles to run the same set of discussion with a new group of people.

Please let me know if anyone know how I should find those, or any ideas to retrieve data from those topics with nested topic\_id.

I really appreciate your help in advance!

---

_[View the full topic](https://meta.discourse.org/t/posts-under-topics-with-nested-topic-id-unincluded/90702)._
