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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:07:54+00:00 2026-06-10T06:07:54+00:00

I am making something like an announcement board that requires readers to acknowledge that

  • 0

I am making something like an announcement board that requires readers to acknowledge that they read it, and was wondering if there is a more efficient way of doing this.

I have 3 Tables on MySQL side:

    +-----------------+        +-----------------+        +-----------------+
    |  Announcements  |        | Acknowledgement |        |      User       |
    +-----------------+        +-----------------+        +-----------------+
    | announce_id     |        | ack_id          |        | user_id         |
    | announce_msg    |        | announce_id     |        | user_name       |
    | ...             |        | user_id         |        | ...             |
    +-----------------+        +-----------------+        +-----------------+

When a user “reads” the announcement (by clicking a button), Acknowledgment table will be inserted with the Announcement ID and User ID. When a second user “reads” the same announcement, Acknowledgement table will be inserted again with same Announcement ID and the second User ID and so on…

    +--------------------------------+
    |        Acknowledgement         |
    +--------+-------------+---------+
    | ack_id | announce_id | user_id |
    +--------+-------------+---------+
    |   1    |      1      |    1    |
    |   2    |      1      |    4    |
    |   3    |      1      |    3    |
    |   4    |      3      |    1    |
    |   5    |      3      |    6    |
    |   6    |      3      |    2    |
    +--------+-------------+---------+

Now to the problem. On the front end, when I list all the announcements on a page, I would have to first query for all the announcements. Then, for each announcement, I would have to do another query for all the users that have read this announcement.

 $sql = "select * from Announcements";
 $result = $pdo->query($sql);
 while ($row = $result->fetch())
 {
   $announce_id = $row['announce_id'];
   $announce_msg = $row['annouce_msg'];
   $readers = "";

   $sql2 = "select u.user_name from Acknowledgement as a INNER JOIN User as u where announcement_id =".$annouce_id;
   $result2 = $pdo->query($sql);
   while ($row2 = $result2->fetch())
   {
     $readers .= $row2['user_name'].", ";
   }

   echo "id:".$annouce_id.", message:".$announce_msg.", Readers:".$readers;
 }

So if there 10 announcements on the page, there will be 10 sub-queries for each announcement. What I have now does the job right now… but what if there is 1000 announcements? Then there will be 1000 sub-queries? Sounds like the database will be really hammered. So I’m hoping there is a better way of doing this.

Also, if 1000 people in the user table reads all 1000 announcements, the acknowledgement table will have 1000×1000 entries. seems like the acknowledgement table will become really really long. Will that be a problem as time goes by?

This is a really rough example of what I’m trying to do but it did take me a long time to write all this. If more details is needed let me know.

  • 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-10T06:07:56+00:00Added an answer on June 10, 2026 at 6:07 am

    There is a better way. You can use a single query with group_concat:

    select a.*, group_concat(u.user_name separator ', ') as AllUsers
    from Announcements a join
         Acknowledgement ak
         on a.Announce_Id = ak.Announce_Id join
         User u
         on u.user_ID = ak.User_ID
    group by a.announce_id
    

    This uses the MySQL feature of hidden columns to group by only one column (announce_id) but still pull in a bunch of other columns with no aggregations (everything else pulled in by the “*”).

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

Sidebar

Related Questions

I'm making a program (think: something like Launchy ) that, more or less, goes
is there any possibility to call method just before making object persistent? Something like
rather than use something like yepnope.js is there a simple method/decent plugin that can
I'm making an app that behaves something like the default Messages.app in iPhone where
I'm making a Google Maps-like application for a course at my Uni (not something
Possible Duplicate: PHP take all combinations I'm thinking of making something in PHP that
I am making a content script that does something with the google results webpage.
I'm making a list view control shuttle with add/remove buttons Something like a control
I'm making a chat which is based on long polling (something like this )with
I'm making my android application. And I want to have something like this situation:every

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.