# שימוש באופרטור IN ב-Data Explorer

**URL:** <https://meta.discourse.org/t/using-the-in-operator-in-data-explorer/310503>\
**Category:** Data & reporting\
**Tags:** sql-query\
**Created:** [4 ביוני,‏ 2024,‏ 12:27pm UTC](https://meta.discourse.org/t/using-the-in-operator-in-data-explorer/310503 "2024-06-04T12:27:04Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![albertocottica](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/albertocottica/32/119622_2.png) [@albertocottica](https://meta.discourse.org/u/albertocottica)\
**Post date:** [4 ביוני,‏ 2024,‏ 1:14pm UTC](https://meta.discourse.org/t/using-the-in-operator-in-data-explorer/310503/3 "2024-06-04T13:14:39Z")

</div>

Sure, here goes. The query is used to retrieve the info necessary to generate a custom log file that can be digested by Gource. See: [Custom Log Format · acaudwell/Gource Wiki · GitHub](https://github.com/acaudwell/Gource/wiki/Custom-Log-Format)

```plaintext
-- This query retrieves a list of the latest posts,
-- along with associated user information and topic details.
-- The result is sorted by creation date in ascending order.

-- The selected fields are as follows:
-- timestamp: An ISO 8601 or unix timestamp of when the post was created.
-- username: The username of the user who created the post.
-- type: A hardcoded value 'A' indicating the type of action (in this case, 'Added').
-- topic: The ID of the topic to which the post belongs.
-- post_number: The unique number of the post within its topic.
-- reply_to_post_number: The post number to which this post is a reply (if any).
-- raw: The content of the post, limited to the first 30 characters.
-- category_id: The ID of the category to which the topic belongs.

SELECT 
    p.created_at as timestamp, 
    u.username, 
    'A' as type, 
    p.topic_id as topic, 
    p.post_number as post_number, 
    p.reply_to_post_number as reply_to_post_number, 
    SUBSTRING(p.raw, 1, 30) AS raw,
    t.category_id
FROM
    posts p
JOIN
    users u ON p.user_id = u.id
JOIN
    topics t ON p.topic_id = t.id
WHERE
    t.category_id IN (420, 421, 426)
    AND t.created_at > '2022-01-01'
ORDER BY
    p.created_at ASC
LIMIT 1000

```

---

_[View the full topic](https://meta.discourse.org/t/using-the-in-operator-in-data-explorer/310503)._
