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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:15:49+00:00 2026-06-14T16:15:49+00:00

I am having some problems with the following MySQL situation. I have the following

  • 0

I am having some problems with the following MySQL situation.

I have the following table structure:

+----+---------+-----------------+------------------+--------------------------------------+------------+
| id |  author |    recipient    |        type      |                   data               |     date   |
+----+---------+-----------------+------------------+--------------------------------------+------------+
|  2 |    1    |        0        | added_item       | { "item_id": "18" }                  | 1352982623 |
| 11 |    1    |        7        | started_follow   |                                      | 1353030567 |
|  9 |    1    |        0        | added_collection | { "collection_id": "18" }            | 1352994561 |
| 12 |    7    |        1        | started_follow   |                                      | 1353030952 |
|  8 |    1    |        1        | started_follow   |                                      | 1352987839 |
| 14 |    1    |        0        | added_collection | { "collection_id": "19" }            | 1353056624 |
| 15 |    7    |        0        | added_collection | { "collection_id": "20" }            | 1353056731 |
| 16 |    1    |        7        | started_follow   |                                      | 1353057009 |
| 17 |    7    |        0        | added_item       | { "item_id": "21" }                  | 1353057054 |
| 24 |    2    |        0        | added_image      | { "image_id": "3", "item_id": "23" } | 1353419642 |
| 23 |    2    |        0        | added_item       | { "item_id": "23" }                  | 1353419159 |
| 22 |    2    |        0        | added_collection | { "collection_id": "22" }            | 1353419146 |
| 25 |    2    |        0        | added_image      | { "image_id": "4", "item_id": "23" } | 1353419644 |
| 26 |    2    |        0        | added_image      | { "image_id": "5", "item_id": "23" } | 1353419646 |
| 27 |    2    |        0        | added_collection | { "collection_id": "23" }            | 1353419953 |
| 28 |    2    |        0        | added_item       | { "item_id": "24" }                  | 1353419961 |
| 29 |    2    |        0        | added_image      | { "image_id": "6", "item_id": "24" } | 1353419982 |
| 30 |    2    |        0        | added_item       | { "item_id": "25" }                  | 1353420424 |
| 31 |    2    |        0        | added_image      | { "image_id": "7", "item_id": "25" } | 1353420435 |
+----+---------+-----------------+------------------+--------------------------------------+------------+

What I would like to do is group all stories within a number of seconds, where the author and type fields are the same.

Here’s the query I’m using at the moment, but this does not return all instances of the stories, only the first time each type occurs per users:

SELECT  `activity`.`id` AS  `id` 
FROM  `activity` 
INNER JOIN  `user_privacy` ON  `user_privacy`.`user_id` =  `activity`.`author` 
WHERE (
`activity`.`author` =2
OR  `activity`.`recipient` =2
)
AND  `user_privacy`.`include_stream` =1
GROUP BY ROUND( UNIX_TIMESTAMP( DATE ) /300 ) ,  `type` 
ORDER BY  `activity`.`date` DESC 
LIMIT 300

I have set up an SQLFiddle demo here > http://sqlfiddle.com/#!2/2b5f4/1.

Given the data outlined above, and the query used, I would like to return the following ids:

  • 22
  • 23
  • 24
  • 27
  • 28
  • 29
  • 30
  • 31
  • 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-14T16:15:50+00:00Added an answer on June 14, 2026 at 4:15 pm

    perhaps did you mistook UNIX_TIMESTAMP and FROM_UNIXTIME. Just repalce it and your desired result set is there. fiddle here

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

Sidebar

Related Questions

I'm having some problems building an hierarchistic array structure - I have almost got
I'm having some problems with deserializing an object. I have following classes: Metadatastore: [DataContract]
I'm having some problems with mod rewrite in the following configuration (simplified version): /index.php
The following code is having some problem with the jQuery. <script type="text/javascript"> $(window).load(function() {
I am having a table with the following structure: ITEMS ('id' int(10), 'stock' int(10),
I'm having some problems with the following Query: SELECT v.idnum ,v.full_name ,convert(varbinary(max),s.signature) as Sig
I'm having some problems with the following: I want to get the first visible
im having some problems with jagged arrays stored in session for ASP.net i have
I am having some performance problems that have left me baffled. I am using
I'm having some problems with the following code: private class ClientPluginLoader : MarshalByRefObject {

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.