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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:05:05+00:00 2026-06-17T14:05:05+00:00

Having a hard time with this seemingly VERY simple mysql query: This does not

  • 0

Having a hard time with this seemingly VERY simple mysql query:

This does not work (valid, but returns no rows):

select * from events where type = 'Disposition' AND startDT > '2012-01-01'

All of the following queries DO work off the same data:

select * from events where type = 'Eval' AND startDT > '2012-01-01'    
-- (change the value to Eval it works!)

select * from events where type = 'Disposition' AND addedDT > '2012-01-01' 
-- (search a different date field it works!)

select * from events where type = 'Disposition'  
-- (get rid of the AND it works!)

select * from events where startDT > '2012-01-01'   
-- (again, no AND it works!)

I have tried variations on the bad query, that also do NOT work:

select * from events where `type` = 'Disposition' AND `startDT` > '2012-01-01'
select * from events where `type` = 'Disposition' AND `startDT` > '2012-01-01 00:00:00'
select events.* from events where `type` = 'Disposition' 
    AND `startDT` > '2012-01-01 00:00:00'

(also tried variations on the date, lower case disposition)

I did not have an index on these fields, so I added an index on startDT, then type+startDT (addedDT has one).
NO DIFFERENCE.

startDT and addedDT are DATETIME fields.
type is varchar 30

Any ideas?

—
If this helps, here is the explain output:

BAD ONE:

explain select * FROM `events` WHERE `startDT` > '2012-01-11 00:00:01' AND `type` = "Disposition" limit 1000
"id"    "select_type"   "table" "type"  "possible_keys" "key"   "key_len"   "ref"   "rows"  "Extra"
"1" "SIMPLE"    "events"    "range" "startDT,type"  "type"  "40"    NULL    "1" "Using where"

RIGHT SIDE:

explain select * FROM `events` WHERE `type` = "Disposition" limit 1000
"id"    "select_type"   "table" "type"  "possible_keys" "key"   "key_len"   "ref"   "rows"  "Extra"
"1" "SIMPLE"    "events"    "ref"   "type"  "type"  "32"    "const" "13760" "Using where"

LEFT SIDE:

explain select * FROM `events` WHERE `startDT` > '2012-01-11 00:00:01' limit 1000
"id"    "select_type"   "table" "type"  "possible_keys" "key"   "key_len"   "ref"   "rows"  "Extra"
"1" "SIMPLE"    "events"    "range" "startDT"   "startDT"   "8" NULL    "13760" "Using where"

SCHEMA:

CREATE TABLE `events` (
    `id` VARCHAR(80) NOT NULL,
    `pk` INT(11) NOT NULL AUTO_INCREMENT,
    `addedDT` DATETIME NOT NULL,
    `type` VARCHAR(30) NOT NULL,
    `startDT` DATETIME NOT NULL,
    PRIMARY KEY (`pk`),
    INDEX `addedDT` (`addedDT`),
    INDEX `startDT` (`startDT`),
    INDEX `type` (`type`, `startDT`)
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
AUTO_INCREMENT=29407;

SAMPLE ROWS:

INSERT INTO `events` (`id`, `pk`, `addedDT`, `type`, `startDT`) VALUES ('FBF8CE96-AE86-36C6-3C27-E2AAD042476B', 29406, '2012-12-28 12:59:03', 'Disposition', '2012-12-28 12:59:00');
INSERT INTO `events` (`id`, `pk`, `addedDT`, `type`, `startDT`) VALUES ('12577DB6-9B22-FA73-89BD-E2A5C1764B6D', 29405, '2012-12-28 12:53:32', 'Disposition', '2012-12-28 12:53:00');
  • 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-17T14:05:07+00:00Added an answer on June 17, 2026 at 2:05 pm

    column startDT is of date type in your table, try comparing date as-

    select * from events where `type` = 'Disposition' AND `startDT` > DATE('2012-01-01');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a hard time with this very simple project. Maybe it's because
I'm having hard time with this simple ajax call function sendreq() { $.ajax({ dataType:
I'm having a hard time getting this to work, and I'm hopelessly confused with
i'm having a hard time getting this to work, all I need to do
Having a hard time figuring this one out... does addObjectsFromArray, a convenience method inside
I don't know why I am having a hard time with this, but it's
I'm having hard time googling this. I found a lot of articles but I
I'm having a hard time with this problem, but I've narrowed it down to
Having a hard time doing this simple thing: return 0 instead of null SELECT
I am having a hard time getting this to work file: myclass.hpp Class MyClass

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.