Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8787837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:59:31+00:00 2026-06-13T21:59:31+00:00

I am trying to convert Xoops posts to WordPress. As part of that, I

  • 0

I am trying to convert Xoops posts to WordPress. As part of that, I want to get comment count for a topic. Post and replies are on same “topic_id”. How to count them and post it in to new column?

DB current status

topic_id | subject             |comment_count|
+________+_____________________+_____________+
1    | welcome             | 
1    | Re: welcome         |
2    | hello world         |
2    | Re: hello world     |
2    | Re: hello world     |
3    | hello friends       |

from here I want to take the (count of topic_id – 1) as the number of replays (comment count). Guide me to query in MYSQL

I want to place the output in the same table. (comment_count)

DB expected output

   | topic_id | subject             |comment_count|
   +________+_____________________+_____________+
   | 1   | welcome             | 1 
   | 1   | Re: welcome         | 1
   | 2   | hello world         | 2
   | 2   | Re: hello world     | 2
   | 2   | Re: hello world     | 2
   | 3   | hello friends       | 0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:59:33+00:00Added an answer on June 13, 2026 at 9:59 pm
        select *,t2.comment_count  from table t1 
         join
         (
           select count(*),CONCAT('Re', ' ', subject) 
            as replay,topic_id as comment_count 
            from table 
            where suject=replay group by topic_id
         ) as t2 on t1.topic_id=t2.topic_id 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to convert output from a rest_client GET to the characters that are represented
I´m trying to convert that: <% var obj = Model.Div; %> <script type=text/javascript> var
I trying to convert a NSString that looks like this: @00:00 15 September 2012
I'm trying to convert some code that worked great in VB, but I can't
I am trying to convert an int into three bytes representing that int (big
I'm trying to convert some strings that are in French Canadian and basically, I'd
Trying to convert strings that contain an escaped unicode (ex: \u3400) in the range
Im trying to convert a general tree (tree that have one or more children
I'm trying to convert time that is stored in a database as type string
I'm trying convert all special chars into HTML safe entities on their way into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.