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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:35:49+00:00 2026-05-26T03:35:49+00:00

I have the following MySQL query: SELECT SUM(IF(num_content>3,3,num_content)) FROM ( SELECT DATE(FROM_UNIXTIME(content_timestamp)) as dt,

  • 0

I have the following MySQL query:

SELECT SUM(IF(num_content>3,3,num_content)) 
FROM
(
SELECT DATE(FROM_UNIXTIME(content_timestamp)) as dt, COUNT(id) as num_content
FROM content     
WHERE author = 'newbtophp'
GROUP BY DATE(FROM_UNIXTIME(content_timestamp))
)a

Which returns the a count of content (from a specific content author) but with the following restriction => it will only consider a maximum of 3 rows of data per day (using the content_timestamp).

It is working fine, however now I’m wanting to return all ids (do a query then a while loop with mysql_fetch_assoc) which fall under that restriction, I’ve tried the following query:

SELECT id 
FROM
(
SELECT DATE(FROM_UNIXTIME(content_timestamp)) as dt, COUNT(id) as num_content, id      FROM content     
WHERE author = 'newbtophp'
GROUP BY DATE(FROM_UNIXTIME(content_timestamp))
)a

But no luck (as its not returning the ids with the restriction).

The main issue for me is I’m not sure how to integrate the restriction whilst returning the ids.

I appreciate all responses.

  • 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-26T03:35:49+00:00Added an answer on May 26, 2026 at 3:35 am

    There certainly must exist a more efficient solution (JOIN), but the following is readable:

    SELECT id, content_timestamp
    FROM content c
    WHERE author = 'newbtophp'
    AND (SELECT COUNT(*)
         FROM content
         WHERE DATE(FROM_UNIXTIME(content_timestamp)) = DATE(FROM_UNIXTIME(c.content_timestamp))
         AND content_timestamp < c.content_timestamp
        ) < 3
    ORDER BY content_timestamp
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following MySQL query: SELECT (COUNT(id) * 5) AS total FROM content
I have the following simple MySQL query, called from PHP: SELECT foo_id, SUM(number_of_guests) FROM
I have following MySQL query: (SELECT c.Channel as name, count(*) as total_episode FROM (
I have the following query in mysql 5.1.41: select distinct table_schema from information_schema.tables where
I have the following MySQL query that I execute from a .php page SELECT
I have the following query: SELECT SUM(COUNTED) AS TCOUNTED FROM (SELECT COUNTED FROM `clicks`.`t1`
I have the following MySql query: select t1.* from Table1 t1 inner join Table2
I have a problem with the following MySQL query: SELECT * FROM TPDSessions WHERE
so I have the following query: SELECT DISTINCT d.iID1 as 'id', SUM(d.sum + d.count*r.lp)/sum(d.count)
I have the following MySQL query: $imgDimensions_query = SELECT imgWidth, imgHeight FROM ( SELECT

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.