need help with a select and order problem

D

Dan

I have a forum running on ASP that allows people to set how many days
they want to see of messages (cutoffdate). The board is set up with
the following select statement - "SELECT * FROM Forum WHERE
DateCreated > cutoffdate ORDER BY ThreadID, FieldSortCode" The
threadid is a sequential number for new threads and the fieldsortcode
is sequential for each reply to the parent thread. For example, a new
thread would get a threadid of 8040 and a sortcode of 8040. A reply
to this thread would get a threadid of 8040 and a sortcode of 8040.1.
It gets a bit more complicated when there's a reply to a reply...but I
think this gives an idea on how the messages are set up.

If someone comes along and replys to a post beyond the person's
cutoffdate, then the reply shows up at the very bottom of the message
board as it should based on threadid and sortcode. Is it possible to
construct a select statement that would order a message with a parent
message beyond the cutoff date at the top of the list. So when
someone replys to a message that is beyond the cutoff date, it will
show up at the top and not at the bottom? I'm thinking I might have
to order by date and sort code and not by sort code alone? Or am I
dreaming?

Dan
 
C

Chris Hohmann

Dan said:
I have a forum running on ASP that allows people to set how many days
they want to see of messages (cutoffdate). The board is set up with
the following select statement - "SELECT * FROM Forum WHERE
DateCreated > cutoffdate ORDER BY ThreadID, FieldSortCode" The
threadid is a sequential number for new threads and the fieldsortcode
is sequential for each reply to the parent thread. For example, a new
thread would get a threadid of 8040 and a sortcode of 8040. A reply
to this thread would get a threadid of 8040 and a sortcode of 8040.1.
It gets a bit more complicated when there's a reply to a reply...but I
think this gives an idea on how the messages are set up.

If someone comes along and replys to a post beyond the person's
cutoffdate, then the reply shows up at the very bottom of the message
board as it should based on threadid and sortcode. Is it possible to
construct a select statement that would order a message with a parent
message beyond the cutoff date at the top of the list. So when
someone replys to a message that is beyond the cutoff date, it will
show up at the top and not at the bottom? I'm thinking I might have
to order by date and sort code and not by sort code alone? Or am I
dreaming?

Dan

Please provide the following:
1. Database
2. Version
3. Data Definition Language (CREATE TABLE ...)
4. Sample Data
5. Desired output

-Chris Hohmann
 
R

roger

"Dan" wrote
If someone comes along and replys to a post beyond the person's
cutoffdate, then the reply shows up at the very bottom of the message
board as it should based on threadid and sortcode. Is it possible to
construct a select statement that would order a message with a parent
message beyond the cutoff date at the top of the list.

Does this work?

SELECT * FROM Forum WHERE
DateCreated > cutoffdate ORDER BY (DateCreated > cutoffdate), ThreadID,
FieldSortCode

Of course, I'm only guessing about the following -

True = -1
False = 0
That the syntax works on your version of SQL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top