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 4324934
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:11:58+00:00 2026-05-21T09:11:58+00:00

SELECT t.thread_id, t.subject, u.username, COUNT(p.post_id) – 1 AS responses, MAX(DATE_FORMAT(p.posted_on, ‘%e-%b-%y %l:%i %p’)) AS

  • 0
    SELECT t.thread_id, t.subject, u.username,
    COUNT(p.post_id) - 1 AS responses, 
    MAX(DATE_FORMAT(p.posted_on, '%e-%b-%y %l:%i %p')) AS last,
    MIN(DATE_FORMAT(p.posted_on, '%e-%b-%y %l:%i %p')) AS first
    FROM threads AS t
    INNER JOIN posts AS p USING (thread_id)
    INNER JOIN users AS u ON t.user_id = u.user_id
    WHERE t.cat_id = 1
    GROUP BY (p.thread_id) ORDER BY last DESC

I thought I did this right, however my query is only returning one row, I have 4 rows where t.cat_id = 1. Any ideas?

EDIT**
SAMPLE DATA
http://i56.tinypic.com/f1e449.png

Right now im only getting just one result:

1  THREAD1  USER1  8  17-Apr-11 6:22 AM  17-Apr-11 3:58 AM

I was expecting to get something like:

1  THREAD1  USER1  8  17-Apr-11 6:22 AM  17-Apr-11 3:58 AM
2  THREAD2  USER1  8  17-Apr-11 6:22 AM  17-Apr-11 3:58 AM
3  THREAD3  USER1  8  17-Apr-11 6:22 AM  17-Apr-11 3:58 AM
  • 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-05-21T09:11:58+00:00Added an answer on May 21, 2026 at 9:11 am

    Chances are that there are no corresponding rows in one of the join tables:

    INNER JOIN posts AS p USING (thread_id)
    INNER JOIN users AS u ON t.user_id = u.user_id
    

    Another possibility (not mutually exclusive of the first) is that the grouping clause collapses the rows.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function get_tags_by_criteria($gender_id, $country_id, $region_id, $city_id, $day_of_birth=NULL, $tag_id=NULL, $thread_id=NULL) { $query = SELECT tags.* FROM
<table class=table table-striped> <thead> <tr> <th>Select</th> <th>From</th> <th>Subject</th> <th>Date</th> </tr> </thead> <tbody> <?php //show
I'm using this MySQL query, called by MySQL: SELECT tf_posts.*, tf_threads.thread_id FROM tf_threads LEFT
I'm running: PostgreSQL 9.0.3 (Last Debian stable) This query: SELECT * FROM sis.thread_categories stc,
<?php $mysqli=mysqli_connect(localhost,root,,politicalforum); $query=SELECT query_title FROM administrator; $query.=SELECT thread_id FROM threads; if($mysqli->multi_query($query)) { do {
I want to select, say, the last 1/x portion of rows from a query,
I'm using the following SQL statement: SELECT reply.id, reply.content, author.username FROM thread, reply, author
I am trying to implement something like: Select thread from Thread where(Select Sum(thread.emails) from
I'm trying to select an select element by name I found this thread showing
SELECT REPLACE([strUrl], '/myoldurl', '/mynewurl') FROM [UrlRewrite] If strUrl is /myoldurl/myoldurl_something_else , it returns /mynewurl/mynewurl_something_else

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.