Forum Reply Count SQL

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default Forum Reply Count SQL

    I have an Access database table for a user forum I creating with ASP. I have
    two ID fields for each message:

    "msg_ID" as the primary key for each message

    and "msg_parentID" to reference which message is being replied to.

    The problem is this: I can't figure out the query to run so that I can include
    a "# of Replies" column in the message list on the page. Will this be easier to
    acheive by doing a query in Access and referencing that, or writing the whole
    query code in the page itself (or perhaps within the repeated region of the
    message list)?

    Any help would be very much appreciated. Thanks.

    JimCloud Guest

  2. Similar Questions and Discussions

    1. Forum error -- Reply title/subject being corrupted.
      The last few days, when posting replies on this forum, the reply subject is not set correctly for me. It is usually a post or two behind. For...
    2. Forum error -- Reply title/subject being corrupted
      The last few days, when posting replies on this forum, the reply subject is not set correctly for me. It is usually a post or two behind. For...
    3. reply
      What kind of problems ? Please explain with error messages, etc. Would be nice also to give some details of your system (Operating System) Ray
    4. do not reply
      Don't tell me what to do! "Dave Slater" <elninia@nospam.adelphia.net> wrote in message news:uIXXa.9708$jg.2578237@news1.news.adelphia.net...
    5. Hi - asp.net forum reply
      dito "news.microsoft.com" <clopper.clopper@totalise.totalise.co.co.uk.uk> wrote in message news:eRMhT8oNDHA.2460@TK2MSFTNGP10.phx.gbl... it
  3. #2

    Default Re: Forum Reply Count SQL

    .oO(JimCloud)
    >I have an Access database table for a user forum I creating with ASP. I have
    >two ID fields for each message:
    >
    > "msg_ID" as the primary key for each message
    >
    > and "msg_parentID" to reference which message is being replied to.
    >
    > The problem is this: I can't figure out the query to run so that I can include
    >a "# of Replies" column in the message list on the page.
    The easiest way to solve that is to add a third ID field to each message
    containing the thread ID, i.e. the ID of the first message in a thread.
    Then all you have to do is to get the first message, grab its ID and
    count how many other messages belong to that thread.

    But if you want to show the number of replies for every single message
    then it will become a bit more complicated ...

    Micha
    Michael Fesser Guest

  4. #3

    Default Re: Forum Reply Count SQL

    If I do add that third db field, what would the sql be to count the messages for each thread?
    JimCloud Guest

  5. #4

    Default Re: Forum Reply Count SQL

    Maybe something like

    select *,
    (
    select count(*) from messages b
    where b.parentid=a.msgid
    ) as messagescount
    from messages a

    --
    Jules
    [url]http://www.charon.co.uk/charoncart[/url]
    Charon Cart 3
    Shopping Cart Extension for Dreamweaver MX/MX 2004



    Julian Roberts Guest

  6. #5

    Default Re: Forum Reply Count SQL

    Figured it out. Thanks anyway!
    JimCloud Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139