Professional Web Applications Themes

Need Help with Count - Macromedia ColdFusion

Basically I have to tables Forum_Main_Thread: Hello (ID 1) Hey (ID 2) Forum_Replies Test (ReplyToID 1) Test2 (ReplyTo ID 1) I am wanting it to get the replies to each thread.. so I am using this to show the threads: <cfquery name='get_main_topic' datasource='aeris7282'> Select * From Forum_Main_Thread </cfquery> <cfoutput query='get_main_topic'> #Topic# but next to the topics i want it to show how many replies there are... i do not know how to use the count() in this situation, can someone guide me? What it should show is: Hello: 2 Hey: 0...

  1. #1

    Default Need Help with Count

    Basically I have to tables Forum_Main_Thread: Hello (ID 1) Hey (ID 2)
    Forum_Replies Test (ReplyToID 1) Test2 (ReplyTo ID 1) I am wanting it to get
    the replies to each thread.. so I am using this to show the threads: <cfquery
    name='get_main_topic' datasource='aeris7282'> Select * From Forum_Main_Thread
    </cfquery> <cfoutput query='get_main_topic'> #Topic# but next to the
    topics i want it to show how many replies there are... i do not know how to
    use the count() in this situation, can someone guide me? What it should show
    is: Hello: 2 Hey: 0

    TylerStonestreet Guest

  2. #2

    Default Re: Need Help with Count

    just use the recordcount feature :)

    If you have a query named "get_main_topic", you can use #get_main_topic.recordcount# to show the number of records pulled from the database.
    MikesWebDesign Guest

  3. #3

    Default Re: Need Help with Count

    Can you show me how i'd do that? i would think it'd have to be a loop since i have many tables being showed..and getting the replies to each one.
    TylerStonestreet Guest

  4. #4

    Default Re: Need Help with Count


    TylerStonestreet wrote:
    > Can you show me how i'd do that? i would think it'd have to be a loop
    since i have many tables being showed..and getting the replies to each
    one.

    I have to guess at your table design because you didn't include it, but
    try something like this:

    select t1.ID, t1.topic, count(t2.replytoID)
    from forum_main_thread t1 inner join forum_replies t2 on t1.ID =
    t2.replytoID
    group by t1.ID, t1.topic

    JR

    Jon Robertson Guest

Similar Threads

  1. Count ()
    By Angelosalsa in forum Coldfusion Database Access
    Replies: 0
    Last Post: February 17th, 03:57 AM
  2. [PHP] COUNT(*)
    By Richard Baskett in forum PHP Development
    Replies: 0
    Last Post: August 1st, 08:39 AM
  3. COUNT(*)
    By Craig Roberts in forum PHP Development
    Replies: 0
    Last Post: August 1st, 08:39 AM
  4. count
    By dennis in forum Microsoft SQL / MS SQL Server
    Replies: 0
    Last Post: July 7th, 07:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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