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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:21:37+00:00 2026-06-02T05:21:37+00:00

I have the following database table below I want to display notification to the

  • 0

I have the following database table below
enter image description here

I want to display notification to the user with owner_id 1. The notification show tell the owner that two users (with ids 17 and 2) commented on his/her post with post_id 1.
I’ve tried the following query but it returns 2 rows instead. How can I can structure the query to return one row, because I want the notifications for one post to be returned together? Thank you.

SELECT DISTINCT commenters_id, id, owner_id, 
                post_id, type, UNIX_TIMESTAMP(date_done) AS date 
FROM notification 
GROUP BY commenters_id 
HAVING owner_id = '$user_id' AND commenters_id != '$user_id' 
ORDER BY date_done DESC
  • 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-02T05:21:40+00:00Added an answer on June 2, 2026 at 5:21 am

    This code will not give you the commenters_id, but instead a count of how many people have replied to each post. The date will be the last time someone replied to that specific post:

    SELECT
        COUNT(DISTINCT commenters_id) AS commenter_count,
        owner_id,
        post_id,
        type,
        UNIX_TIMESTAMP(MAX(date_done)) AS date 
    FROM notification
    WHERE owner_id = '$user_id' AND commenters_id != '$user_id' 
    GROUP BY owner_id, post_id, type
    ORDER BY UNIX_TIMESTAMP(MAX(date_done)) DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following listbox below which binds to a database table of image
I have the following table in my database. Now what I want to find
I have a table that is similar to the following below: id | cat
I have a sample database like below, and I want to display only the
Let's say I have the following database table: record_id | record_date | record_value -----------+-------------+--------------
I have the following table in a SQLite3 database: CREATE TABLE overlap_results ( neighbors_of_annotation
I have the following table and sequence in my postgresql-8.4 database: CREATE TABLE complexobjectpy
Say I have a database table like the following: FileID | FileName | FileSize
I have the following table in my postgreSQL 8.3.14 database timestamp status 2012-03-12 19:15:01
I have no control over database schema and have the following (simplified) table structure:

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.