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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:56:05+00:00 2026-05-29T06:56:05+00:00

I have a table for appointments containing dates and Pupil IDs which I am

  • 0

I have a table for appointments containing dates and Pupil IDs which I am trying to get to automatically duplicate on a weekly basis. I want to run a query which detects if each appointment has a copy of itself a week ahead, so original data was:

PupilID   Date
1         10th May
2         16th May

After the query,

PupilID   Date
1         10th May
2         16th May
1         17th May
2         23rd May

I am trying to use the following with no luck. Suggestions would be much appreciated. I have code doing the job already, but it is getting really slow.

INSERT timetable (pupil_id,date) SELECT timetable.pupil_id AS pupil_id2,DATE_ADD(timetable.date,INTERVAL 14 DAY) AS date2 FROM timetable WHERE  NOT EXISTS pupil_id2=timetable.pupil_id AND date2=timetable.date;
  • 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-29T06:56:06+00:00Added an answer on May 29, 2026 at 6:56 am

    Would it be sufficient to check whether there was a future appointment at all?

    Give this a shot:

    insert into timetable (pupil_id,date)
    select t.pupil_id, DATE_ADD(t.date, INTERVAL 14 DAY)
    from timetable t 
    where not exists (select 1 from timetable
                             where pupil_id = t.pupil_id
                             and date > t.date)
    

    You could change the last clause to specifically check for the 14 days ahead:

    where not exists (select 1 from timetable
                             where pupil_id = t.pupil_id
                             and date = DATE_ADD(t.date, INTERVAL 14 DAY))        
    

    I recommend the first query though.

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

Sidebar

Related Questions

I have an appointments table which saves 2 times. start and end. I want
Given I have a model/table with appointments, saved as a date. I want to
I have a table of Appointments and a table of AppointmentOutcomes. On my Appointments
i have table structure with 3 colums (column1, column2, column3) and i want to
I have table with 3 columns A B C. I want to select *
I have table which has a class data and it has table rows inside
I have table which will only contain information about files, so, as the file
Hi all I have an appointments table that has among other fields a DATE
I have two tables in my app: 'Clients' and 'Appointments' In the appointments table
I have a database table which records all field changes in all database tables

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.