Log in

View Full Version : SQL Statement Help


SDB
08-20-2007, 09:56 AM
Hi All

I'm struggling with this.

I want a SQL statement to request :

A list of thread ids (not repeating the same threadid twice)
That userid 888 has - at some point - posted in
and where lastpostuserid <> 888 (ie, someone has posted since)
ordered by lastpost desc

In other words, this will be a list of thread ids, that the user has posted in, that have received a reply since he posted, and in order of newest first.

Thanks in advance

Eikinskjaldi
08-20-2007, 11:54 AM
Hi All

I'm struggling with this.

I want a SQL statement to request :

A list of thread ids (not repeating the same threadid twice)
That userid 888 has - at some point - posted in
and where lastpostuserid <> 888 (ie, someone has posted since)
ordered by lastpost desc

In other words, this will be a list of thread ids, that the user has posted in, that have received a reply since he posted, and in order of newest first.

Thanks in advance


SELECT DISTINCT p.threadid from
post p JOIN thread t USING (threadid)
WHERE userid=888
AND lastposter != username
order by t.dateline desc


coul dbe p.dateline in the order, depending on your definition of "newest"

SDB
08-20-2007, 12:46 PM
Thank you!