PDA

View Full Version : SQL select only not-deleted posts in a thread


smdani
02-02-2005, 09:24 PM
I would like to build a SQL sentence where can get all postids from a thread, but no those who has been deleted.
I tried this:
SELECT postid FROM post WHERE ((threadid=$tid) AND (visible=1)) ORDER BY postid DESC")
But it keeps gettin me deleted posts, because they have visible=1.

Any help?

Thanks in advance!

Dean C
02-03-2005, 05:27 AM
SELECT postid FROM post WHERE ((threadid=$tid) AND (visible<>1)) ORDER BY postid DESC")


<> is the MySQL NOT operator :)

Xenon
02-03-2005, 03:14 PM
Dean i think he meant something different

you have to join the deletion log table:

SELECT *
FROM post
LEFT JOIN deletionlog ON(deletionlog.primaryid = post.postid AND type = 'post')
WHERE deletionlog.primaryid IS NULL

smdani
02-03-2005, 04:01 PM
That is!
Thanks a lot

Xenon
02-03-2005, 04:47 PM
you're welcome