# Find users who read specific topics

**URL:** <https://meta.discourse.org/t/find-users-who-read-specific-topics/100657>\
**Category:** Data & reporting\
**Tags:** sql-query\
**Created:** [10월 28, 2018, 4:04오전 UTC](https://meta.discourse.org/t/find-users-who-read-specific-topics/100657 "2018-10-28T04:04:16Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
**Post date:** [10월 30, 2018, 2:21오전 UTC](https://meta.discourse.org/t/find-users-who-read-specific-topics/100657/11 "2018-10-30T02:21:56Z")

</div>

> [@Henry\_Cooper](#):
>
> This only shows me if the users who posted in the topic likes the post. Doesnt show if someone just comes in likes and leaves without posting?

That’s right. You can alter the query so that it doesn’t only select users who have posted by removing this part:

```plaintext
AND tu.posted = true

```

Try this:

```plaintext
-- [params]
-- int :topic_id

WITH user_data AS (
  SELECT u.username,
    ue.email,
    tu.topic_id,
    tu.posted,
    tu.liked
    FROM users u
    JOIN topic_users tu ON u.id = tu.user_id 
    JOIN user_emails ue on u.id = ue.user_id
    ORDER BY tu.last_visited_at DESC
)
SELECT * FROM user_data WHERE topic_id = :topic_id

```

---

_[View the full topic](https://meta.discourse.org/t/find-users-who-read-specific-topics/100657)._
