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

  • Home
  • SEARCH
  • 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 7691793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:42:16+00:00 2026-05-31T20:42:16+00:00

I have a follow-up question regarding an issue I previously had on SO here

  • 0

I have a follow-up question regarding an issue I previously had on SO here. I would like to know how to further optimize/refine my issue.

My old query was:

-- OLD QUERY --
SELECT start, end, title, details, location
FROM event
WHERE (start >= 2012-02-26 00:00:00 AND end <= 2012-04-01 00:00:00)
AND user_id= $user_id;

This query works great because it does not get old events, say from January. So the query is fast and efficient. But, it does not work for queries that may overlap into the next month. (Let’s say an event has a “start_date” of 2012-03-29, but an “end_date” of 2012-04-05. Well, then it’s not pulled in the query, thus, not displaying.

So, my new query ended up being:

-- NEW QUERY --
SELECT start, end, title, details, location
FROM event
WHERE (end > 2012-02-26 00:00:00 OR start < 2012-04-01 00:00:00)
AND user_id= $user_id;

But, with the new query, it ends up pulling ALL events prior to 02-26-2012, thus making it VERY slow and inefficent.

How can I optimize this query to achieve both of these:

a) Make it work so that it gathers events that span the end of one month into another?
b) And at the same time NOT query every single other event in the past?

Hopefully there’s a way to do this! Thanks very much for any input.

  • 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-31T20:42:17+00:00Added an answer on May 31, 2026 at 8:42 pm

    To find overlapping events, change OR to AND in your query (changed the dates slightly to get overlaps with March only):

    WHERE (end >= '2012-03-01' AND start < '2012-04-01')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have also a question regarding distinct and/or group by. My table as follow:
I have recently started with XML and had a question regarding XML schemas. As
I have a follow-up question to this one . I created a new form,
I have a follow up question to this question . Is it possible to
I have a follow up question to this one . Now that I have
What are extension methods in .NET? EDIT: I have posted a follow up question
I have the follow structure (example): trunk/ branches/v1.0.0 branches/v1.0.1 tags/v1.0.0 My question is: The
this is a follow-up question of mine. Suppose now I have a URL :
This is somewhat of a follow-up question to this question . Suppose I have
Follow up to this question . I have the following code: string[] names =

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.