# User posts export as csv or text

**URL:** <https://meta.discourse.org/t/user-posts-export-as-csv-or-text/273232>\
**Category:** Data & reporting\
**Tags:** sql-query\
**Created:** [July 29, 2023, 3:34pm UTC](https://meta.discourse.org/t/user-posts-export-as-csv-or-text/273232 "2023-07-29T15:34:26Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [July 31, 2023, 12:20pm UTC](https://meta.discourse.org/t/user-posts-export-as-csv-or-text/273232/6 "2023-07-31T12:20:06Z")

</div>

Including `t.user_id` would only give posts where the user was also the OP. Could that be the main issue?

I noticed a couple of extra bits that may be useful too. Something like:

```sql
-- [params]
-- user_id :user

SELECT t.id AS topic_id, 
       t.title, 
       p.raw as text, 
       p.created_at as dateposted
FROM posts p
JOIN topics t ON t.id = p.topic_id
WHERE t.archetype != 'private_message'
  AND p.post_type IN (1, 4)
  AND p.user_id = :user
  AND t.deleted_at ISNULL
  AND p.deleted_at ISNULL
ORDER BY p.created_at

```

---

_[View the full topic](https://meta.discourse.org/t/user-posts-export-as-csv-or-text/273232)._
