Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Location
    Denmark
    Posts
    9

    Exclamation Unanswered: The right SQL-statement

    It seems I am the first on the Internet having a problem with this. So either I am trying something impossible, or I am so stupid that nobody needs to write it down on any homepage.

    My problem is some SQL-statement.
    I am writing a forum (www.denemarken.prikbord.franl.dk). I use VBScript / ASP as language, and Microsoft Access 2000 as database. I am having MDAC 2.8 installed on my server.
    The table in the database has following fields:

    - ID (AutoNumber)
    - ReplyID (= 0 if a new message is postet, or "ID" of the original message, if the message is a reply)
    - BaseID (ID of the first message in a topic range
    - Date
    - Time
    - Subject
    - Text
    - IP
    - Name
    - Email
    - Position

    All subjects are ordered by reply, which means, that a reply on a message appears in a list right under the original message, with to spaces ( in front of the subject. And if there comes a reply on a reply, it simply adds two more spaces, and appears right under the last message.

    Such as these:

    Message (ID:1, ReplyID:0, BaseID: 1)
    --Re: Message (ID:2, ReplyID:1, BaseID: 1)
    ----Re: Message (ID:3, ReplyID:2, BaseID: 1)

    Now comes the tricky part. Look at this:

    Message (ID:1, ReplyID:0, BaseID: 1)
    --Re: Message (ID:2, ReplyID:1, BaseID: 1)
    ----Re: Message (ID:3, ReplyID:2, BaseID: 1)
    ------Re: Message (ID:4, ReplyID:3, BaseID: 1)
    --------Re: Message (ID:5, ReplyID:4, BaseID: 1)
    ----Re: Message (ID:6, ReplyID:2, BaseID: 1)
    ------Re: Message (ID:7, ReplyID:6, BaseID: 1)
    --------Re: Message (ID:8, ReplyID:7, BaseID: 1)
    ------Re: Message (ID:9, ReplyID:6, BaseID: 1)
    --------Re: Message (ID:10, ReplyID:9, BaseID: 1)

    Now my question is: WHICH SQL Statement am I supposed to use? At this moment, I am using

    Select ID, ReplyID, Name, Email, IP, Subject, Text, Date, Time, Position, BaseID from forum ORDER BY BaseID, Position, Date, Time ASC

    Yours,

    Albert van Harten
    Denmark

  2. #2
    Join Date
    Nov 2003
    Location
    Bangalore, INDIA
    Posts
    333
    HI,

    Try with this Query

    SELECT ID
    , ReplyID
    , Name
    , Email
    , IP
    , Subject
    , Text, Date
    , Time
    , Position
    , BaseID
    FROM forum
    ORDER BY BaseID
    , ID
    , Date
    , Time ASC
    ;
    SATHISH .

  3. #3
    Join Date
    Sep 2003
    Location
    Denmark
    Posts
    9

    Cool Thanks

    Thanks for the reply. I already tried that one, but thanks anyway.
    Together with an expert from Denmark, I got a solution, which is much more complicated than just an SQL-query.

    Yours sincerely,


    Sovetryne

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •