mysql - Select all records that where added less than a month ago and more than a month ago with a score of X -


from table below, i'm trying select records that:

  • have been added within last month (regardless of score)
  • records added more month ago , have score of >= 10

my efforts below, i'm going wrong somewhere

select id candidates  dateenrolled >= date_sub(now(), interval 1 month)  , dateenrolled <= now() , score >=10; 

i keep getting on 7 , 8. right answer should include following ids 1 2 5 6 7 8 9 10

can please help?

"id"    "dateenrolled"  "score" "1"     "2013-01-01"    "12" "2"     "2013-02-01"    "15" "3"     "2013-03-01"    "9" "4"     "2013-04-01"    "8" "5"     "2013-05-01"    "20" "6"     "2013-08-01"    "0" "7"     "2013-08-12"    "10" "8"     "2013-08-13"    "12" "9"     "2013-08-15"    "1" "10"    "2013-08-17"    "5" 

try like

select id candidates dateenrolled >= date_sub(now(), interval 1 month)       or (dateenrolled <= now() , score >=10); 

swap and selector or.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -