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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:18:53+00:00 2026-06-02T07:18:53+00:00

This query returns me the list of room #077 that is occupied on specific

  • 0

This query returns me the list of room #077 that is occupied on specific day; how do I reverse this query and show only times that are NOT in the database between 07:00:00 and 22:00:00? (30 minutes intervals) and each class should take only 1 hour and 30 minutes

select 
    *
from
    (select 
        rooms.id, rooms.number, rooms.building, rooms.capacity
    from
        rooms) R1,
    (select 
        exam_schedules.room_id,
            exam_schedules.day,
            exam_schedules.start_time,
            exam_schedules.end_time
    from
        exam_schedules) R2
where
    R2.room_id = R1.id and R2.day = 'tuesday' and R1.number = '077'

This is the result:

ID  number  Bulding Capacity    room_id day start_time  end_time
1   077 ACT 12  1   tuesday 10:30:00    12:00:00

But I need the result that is shown below (which is pretty much shows the AVAILABLE times that are NOT occupied by exams AND could no be occupied by other exam since it might cause scheduling issues: for example if exam is already scheduled at 10.30, only 9.00 (not 9.30) should be shown since if 9.30 is shown – it will cause the conflict: 9.30+1.30 = 11.00 – but I already have the 10.30-12.00 scheduled for this room)

 1  077 ACT 12  1   tuesday 07:00:00
 1  077 ACT 12  1   tuesday 07:30:00
 1  077 ACT 12  1   tuesday 08:00:00
 1  077 ACT 12  1   tuesday 08:30:00
 1  077 ACT 12  1   tuesday 09:00:00
//note that time frame from 9.30-10.30 is not available since there is a class at 10.30 scheduled already
//note that time period 10.30-<12.00 not shown since class is already scheduled for this timeframe 10.30-12.00
 1  077 ACT 12  1   tuesday 12:00:00
 1  077 ACT 12  1   tuesday 12:30:00
 1  077 ACT 12  1   tuesday 13:00:00
 1  077 ACT 12  1   tuesday 13:30:00
 1  077 ACT 12  1   tuesday 14:00:00
 1  077 ACT 12  1   tuesday 14:30:00
 1  077 ACT 12  1   tuesday 15:00:00
 1  077 ACT 12  1   tuesday 15:30:00
 1  077 ACT 12  1   tuesday 16:00:00
 1  077 ACT 12  1   tuesday 16:30:00
 1  077 ACT 12  1   tuesday 17:00:00
 1  077 ACT 12  1   tuesday 17:30:00
 1  077 ACT 12  1   tuesday 18:00:00
 1  077 ACT 12  1   tuesday 18:30:00
 1  077 ACT 12  1   tuesday 19:00:00
 1  077 ACT 12  1   tuesday 19:30:00
 1  077 ACT 12  1   tuesday 20:00:00
 1  077 ACT 12  1   tuesday 20:30:00
 1  077 ACT 12  1   tuesday 21:00:00
 1  077 ACT 12  1   tuesday 21:30:00
 1  077 ACT 12  1   tuesday 22:00:00

The table with all possible timeframes does not exist in the database. Can I maybe hadcode it into the query?

  • 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-02T07:18:59+00:00Added an answer on June 2, 2026 at 7:18 am

    You need to create the list of all possible values. You can do this with a query like:
    select *
    from (select ‘2012-01-01 7:00:00’ from dual union all
    select ‘2012-01-01 7:30:00’ from dual union all . . .
    ) times

    That is, you can use union all to put the data together. I find it easiest to use Excel to put together the SQL statements needed to make this work.

    That said, a calendar/calendar-time table is something you should consider. Having a table with each possible time slot it in will probably help you in the future.

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

Sidebar

Related Questions

this query returns the list below it, however the ids occur multiple times, can
I have this query that returns the results by ordering it by focus.name ASC.
I have a LINQ query that returns some object like this... var query =
I currently have a query that returns a list of columns, and one of
I have the following query that returns rows based on a comma seperated list
I am working on my final project and this is the query that returns
I have a query on the server side that returns a list of distinct
I have a linq query that returns a list and the result looks like
Easy one i think/hope... I have a query that returns a list of 20
Can anyone explain why this query returns an empty result. SELECT * FROM (`bookmarks`)

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.