从下表中,我正在尝试选择以下记录:
我的努力在下面,但我在某个地方出错了
select id from candidates
where dateEnrolled >= date_sub(now(), interval 1 month)
and dateEnrolled <= now() and score >=10;
我继续7 and 8
。正确答案应仅包括以下ID 1 2 5 6 7 8 9 10
你能帮忙吗?
"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"
答案 0 :(得分:2)
尝试类似
的内容select id from candidates where dateEnrolled >= date_sub(now(), interval 1 month)
or (dateEnrolled <= now() and score >=10);
将and
选择器换成or
。
答案 1 :(得分:1)
select id from candidates
where dateEnrolled >= date_sub(now(), interval 1 month)
and dateEnrolled <= now()
or (score >=10 and dateEnrolled < date_sub(now(), interval 1 month) );