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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:16:28+00:00 2026-06-06T19:16:28+00:00

I have a scheduled_item table where I can schedule animations to be displayed. Once

  • 0

I have a scheduled_item table where I can schedule animations to be displayed.

Once the animation is played it’s attribute is_played is set to true.

When all animations have been played, the scheduler adds previously displayed animation to the queue, so the screen always plays some animations.

When the new animation arrives it needs to be added ahead of the queue – ideally replace the very next item to be played.

The schedule_item looks like this:

CREATE TABLE scheduled_item (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `animation_id` bigint(20) DEFAULT NULL,
  `is_played` tinyint(1) NOT NULL DEFAULT '0'
);

Some rows could look like this

+----+--------------+-----------+
| id | animation_id | is_played |
+----+--------------+-----------+                                           
| 17 |           15 |         1 |
| 40 |           22 |         1 |
| 43 |           26 |         1 |
| 46 |           15 |         1 |
| 49 |           22 |         0 |
+----+--------------+-----------+

So, I’m trying to get id of the all animations that haven’t been played yet, but have been played in the past. In this case I’m looking for id 49 / animation_id 22.

So this is what I’ve come up with and it seems to be working but:

SELECT item_id
FROM scheduled_item
GROUP BY animation_id
HAVING count( animation_id ) > 1
AND MIN( is_played ) < 1
AND MAX( is_played ) > 0
ORDER BY id ASC;
  • Is there a better way of doing it?
  • Am I getting the right result?
  • 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-06T19:16:29+00:00Added an answer on June 6, 2026 at 7:16 pm

    Try this query – you don’t need a having clause in this case.

    select item_id from scheduled_item 
        where is_played = 0 and 
        item_id in(
            select p.item_id from scheduled_item p 
                 where p.animation_id = animation_id and 
                 p.item_id < item_id and is_played = 1
        )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a structure as <div id =page class=item-page> <table id=schedule> </table> </div> How
I have a table of schedule items, they may be scheduled for the same
I have a list of data that is a schedule. Each item has a
I have an SQL script which creates a scheduled event: CREATE EVENT Daily_1200PM SCHEDULE
I have an application for scheduling certain events. And all these events must be
I have a complex form for a model Schedule that belongs to a parent
i have an application in which a user can lock a certain commodity and
I'm using the Superfish jQuery menu system and have a requirement to show all
I have an mongo query that looks like the following: {'schedule': {'$elemMatch': {'time': {'$gt':
I have a table that stores customer items. The table needs to reflect the

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.