# 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:** [June 25, 2018, 12:54pm UTC](https://meta.discourse.org/t/posts-under-topics-with-nested-topic-id-unincluded/90702 "2018-06-25T12:54:35Z")
**Posts on this page:** 3
**Page:** 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: [June 25, 2018, 12:54pm 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!

---

<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: [June 25, 2018, 1:34pm UTC](https://meta.discourse.org/t/posts-under-topics-with-nested-topic-id-unincluded/90702/2 "2018-06-25T13:34:25Z")

</div>

I figured the first number is the topic number and the second number is the post number..

Looks like I can proceed with the search. Thanks!

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [January 12, 2021, 1:17pm UTC](https://meta.discourse.org/t/posts-under-topics-with-nested-topic-id-unincluded/90702/3 "2021-01-12T13:17:02Z")

</div>


