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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:03:30+00:00 2026-05-16T00:03:30+00:00

I was wondering which type of query is better to use: SELECT * FROM

  • 0

I was wondering which type of query is better to use:

SELECT * FROM table WHERE DATE >= '2010-7-20' AND DATE <= '2010-7-24'

OR

SELECT * FROM table WHERE DATE_SUB('2010-07-24',INTERVAL 4 DAY) <= 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-16T00:03:31+00:00Added an answer on May 16, 2026 at 12:03 am

    I always use the >= and < combination.

    So if you want to serch for a those four days you would use

    where DATE >= '2010-07-20' AND DATE < '2010-07-24'
    

    This ensures that you only get dates your interesrted in even if there’s a mixtrure of acutal dates(with no time component ) and datetimes.

    So if you had a date stored as 2010-07-20 09:00:00 and a date stored as 2010-07-20 they would both be included, but the date 2010-07-24 wouln’t.

    I don’t trust Between!
    I’m not sure about MySQL but BETWEEN in SQL Server would give you inclusive results so a row with a date of 2010-07-24 would be included when I wouldn’t expect it to be if you wanted the four date period from the 20th? (20th, 21st, 22nd & 23rd)

    So ANY date on the 24th shouldn’t be included even if it was midnight..!

    Also…
    Typically using functions in your criteria can prevent the optimizer using any indexes..! Something to be aware of.

    More Importantly…
    The second query doesn’t produce the same results as the first query…Is it all there?

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

Sidebar

Related Questions

I was wondering which way is better to work with. Using private attributes at
I was wondering which could be a better way of mounting different apps for
I came across writing the query in differnt ways like shown below Type-I SELECT
I am wondering which is more efficient, to store temporary data (related to that
I was wondering which kind of expressiveness fits a language used to generate particle
I was wondering which DVCS is most conducive to experimentation i.e. branching, etc. I
I am wondering which way would end up being faster, selecting elements by: $('element[href=#my_link]');
I was wondering which tool in ORACLE 11g (their latest DBMS) can be used
I was wondering which of these two scenario's works best for swapping between 2
I was just wondering which would be cheaper, using a try catch block for

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.