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

  • Home
  • SEARCH
  • 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 166059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:01:53+00:00 2026-05-11T12:01:53+00:00

I have a social networking site where users update their moods, profiles and add

  • 0

I have a social networking site where users update their moods, profiles and add photos.

I’m currently logging all updates in a table called ‘update_log’ with the following structure:

update_id int (auto),  userid int,  update_type int (1=profile, 2=photo, 3=mood) pictureid int mood_a int mood_b int mood_c int update_time int 

Profile update record: (auto), 1, 1, 0, 0, 0, 0, 1239003781

Photo update record: (auto), 1, 2, 11544, 0, 0, 0, 1239003781

Mood update record: (auto), 1, 3, 0, 1, 490, 70, 1239003781

For the photo record, there’s a corresponding table userphotos which holds the caption and filename/location data

For moods, there is a mood lookup table that holds the mood descriptions (i.e., I’m lazy =\ )

What I need to do is query this data to show on a user’s profile page, it will show this feed for any of their favorite users for the last x hours of activity.

The problem I’m running into is that if a user uploads five photos over the course of a half hour or something, I just want that to be one line in the feed, not an entry for each photo upload.

Same goes for profile updates.

I need to query the data so the user will see something like this:

user x updated their mood! (I’m tired) on Apr 4, 2009 10:35 pm
user y uploaded x new photos on April 4, 2009 10:20 pm
user x updated their profile on April 4, 2009 10:15 pm

How do I group the photo updates into one record returned in a query based on all records being within let’s say an hour of each other?

Is there a way to do this with one query?

Thanks!

  • 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. 2026-05-11T12:01:54+00:00Added an answer on May 11, 2026 at 12:01 pm

    You want something like

    SELECT * FROM update_log WHERE update_time > NOW() - 30 MINUTES;

    With 30 minutes being the period of time you’re looking back.

    I’m assuming you just needed to know how to return in a single query the updates of the last 30 minutes.

    If you’re trying to group all of the photos together into 30 minute blocks, say for the last two days, you’d be better off changing your database structure and creating a photo_group table [containing a primary key, userid, and time of creation] and adding a group_id column to the update_log table.

    When adding a new photo, check for an existing group created by that user in the last 30 minutes.

    SELECT * FROM photo_group WHERE user_id = XXX AND created > NOW () - 30 MINUTES;

    If one does not exist, create it. Link the photos to the newest by adding the primary key of the photo_group table as the group_id in the update_log.

    When you retrieve rows later, you can group them by group_id using your scripting language.

    The disadvantage of this method is your grouping structure will be difficult to modify later, as previous entries will be grouped by their old groups when you change the rules for creating new groups.

    If you want to do this without storing the groups, you'll have to handle the logic in your scripting language by grouping the photos together in a loop that checks the creation time of a photo, groups following photos in an array with it if they have been created within a specific time period, or restarts the loop, using the most recent photo that did not fit with the previous. This would be more overhead than adding a new table, but it would be easier to modify later.

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

Sidebar

Ask A Question

Stats

  • Questions 71k
  • Answers 71k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Basically, anything you store in a way accessible to your… May 11, 2026 at 1:16 pm
  • added an answer Not sure if TOAD for specific DB versions is any… May 11, 2026 at 1:16 pm
  • added an answer On both XP and Vista you need Admin rights to… May 11, 2026 at 1:16 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.