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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:30:13+00:00 2026-05-26T13:30:13+00:00

Need help on sql(mysql query) to check that the selected ‘startdate’ and ‘enddate’ does

  • 0

Need help on sql(mysql query) to check that the selected ‘startdate’ and ‘enddate’ does not have any records in that range.

bellow is my table :

---------------------------------------------------------
| id |    start           |     end            |activity|
---------------------------------------------------------
| 1  |2011-10-30 13:00:00 |2011-10-30 14:00:00 | study  |
| 2  |2011-10-30 15:00:00 |2011-10-30 16:00:00 | tennis |
| 3  |2011-10-30 17:00:00 |2011-10-30 18:00:00 | golf   |
| 4  |2011-10-30 18:00:00 |2011-10-30 19:00:00 | gym    |
| 5  |2011-10-30 20:00:00 |2011-10-30 21:00:00 | study  |
---------------------------------------------------------

i hope this post will be usefull for others as well.The start and end columns are datetime data type.Basically the query that i am trying to do is to check for activity clashing.

need help .thank you in advance.

  • 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-26T13:30:13+00:00Added an answer on May 26, 2026 at 1:30 pm

    Basically you need to see if either the start or the end date of one record is inside another row’s start and end dates. I did it with an INNER JOIN. You could also do it with a WHERE' clause instead.

    Select [your fields]
    From table t1
               Inner join table t2
               On t1.id <> t2.id
                   And (( t1.start > t2.start
                        And t1.start < t2.end)
                         Or
                        (t1.end > t2.start
                        And t1.end < t2.end))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an interesting SQL problem that I need help with. Here is the
Need a little help with a SQL / ActiveRecord query. Let's say I have
I need a help constructung an sql query for mysql database. 2 Table as
i need some help with this sql query heres my mysql table structure: DOMAINS
I have the following query, which works in MySQL, and I need help&hints to
I need some help with SQL Query. I am trying to select all records
I'm somewhat new to SQL and need help with query syntax. My issue involves
I need help in indexing in MySQL. I have a table in MySQL with
I desperately need help with a query that's been causing a lot of grief
I need some help to write some queries. For this sql query (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.