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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:10:34+00:00 2026-05-25T13:10:34+00:00

In my events table there are records that have a daily flag that indicate

  • 0

In my events table there are records that have a daily flag that indicate that this event must be repeated each day:

CREATE TABLE IF NOT EXISTS `events` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `start` datetime DEFAULT NULL,
  `title` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `description` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `daily` tinyint(1) NOT NULL,
) ENGINE=InnoDB;

When I try to fill a calendar with this data I need a row for each item, it is, if the calendar ask for all events this week, daily flaged events must return 7 events (one for each week day) with the same data (title, description, etc), but with a different start day.

Is it possible to do from MySQL?

  • 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-25T13:10:34+00:00Added an answer on May 25, 2026 at 1:10 pm

    Usually I would use a table that contains each of the single date.
    Example

    create table daily
    (
       /* FYI, date is not a reserved keyword */
       date date
    );
    
    insert into daily values ('2011-09-11'), ('2011-09-12'), 
    ('2011-09-13'), ('2011-09-14'), ('2011-09-15'), 
    ('2011-09-16'), ('2011-09-17');
    
    alter table daily add index (date);
    
    select daily.date as daily_date, 
           weekly.start, weekly.id, weekly.title, weekly.description
    from daily
    inner join
    (
       select events.id, events.title, 
              events.description, events.start, events.daily
       from events
       where events.start between '2011-09-11' and '2011-09-17'
    ) as weekly
    on date(weekly.start)=daily.date
    union
    /* query for recurr */
    select daily.date as daily_date, 
           recurr.start, recurr.id, recurr.title, recurr.description
    from daily
    inner join
    (
       select events.id, events.title, 
              events.description, events.start, events.daily
       from events
       where events.daily=1 AND events.start between '2011-09-11' and '2011-09-17'
    )as recurr
    on date(recurr.start)<=daily.date
    order by daily_date;
    

    It would be more efficient if you break the start column to two column (date, time).
    The drawback of this method is on the pre-create of table daily and loaded it with lots of day value.

    This should be one time cost and can easily inserted via a for.
    Alternatively, you can do a repeat of (from a week start to week end) on the query for recurr

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

Sidebar

Related Questions

I have this Mysql event that runs every minute to delete records that are
I have a table widget_events that records event_what events occurring to widget widget_id on
My application has one table called 'events' and each event has approx 30 standard
I have table that records logins for users. I'm having trouble finding a query
I have a page that inserts records into a table. what i am having
I'm using PHP and MySQL. I have records for: events with various event types
I have a table (in MS Access) that stores in each record the start
I'm not really sure how to define this. I have a table that has
Given a table of events where each event may be associated with zero or
I have a database table that represents Events. The table has 2 main fields

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.