PDA

View Full Version : Export threads from a single user / Query modification


tischtelefon2
01-17-2017, 05:41 AM
Hi all,

I need a bit support. A good friend of mine died and he actively posted in my forum and started several threads. So I would like to export all threads my friend started including the first post he wrote. I'd like to use this as a kind of memorial for all of his friends.

The following query does a good job to get all of his postings, but I only want to export the threads including the first post. Could anyone help me how to modify the query?

SELECT post.postid, post.threadid, thread.title, post.username, FROM_UNIXTIME(post.dateline) as date, post.pagetext from post, thread WHERE post.threadid = thread.threadid AND post.username = 'XXXXXXXXXX' ORDER BY date;

Thanks so much.

Michael

MarkFL
01-17-2017, 05:49 AM
Try changing:

post.threadid = thread.threadid

to:

post.postid = thread.firstpostid

tischtelefon2
01-17-2017, 05:52 AM
Thanks so much, Mark. Thanks so much.

--------------- Added 1484640652 at 1484640652 ---------------

Mark, I hope it's okay that I ask another question. How do I need to modify the query if I want to extract all threads my friend started including all other postings(I mean replies) of theses threads? So I export the complete thread?

Thanks so much.

Michael

Andr? Noberto
01-19-2017, 10:18 AM
I think would be easier if you do another query to only get the secondary posts.

If you agree with me you can try something like this:

1 - Store threadid and firstpostid into variables.
2 - Query.

SELECT * FROM post WHERE threadid = YourFriendThreadID and postid <> FirstPostID

MarkFL
01-19-2017, 11:47 AM
--------------- Added 1484640652 at 1484640652 ---------------

Mark, I hope it's okay that I ask another question. How do I need to modify the query if I want to extract all threads my friend started including all other postings(I mean replies) of theses threads? So I export the complete thread?

Thanks so much.

Michael

Sorry, I didn't know you had posted another question since the posts were merged. For this, I would run a sub-query, like so:

SELECT post.* FROM post AS post WHERE post.threadid IN (SELECT thread.threadid FROM thread AS thread WHERE thread.postusername = 'XXXXX')