我有这个又长又讨厌的MySQL
查询:
SELECT * FROM
studentdates sd
INNER JOIN
students s ON s.student_id = sd.student_id
INNER JOIN
cityselections cs ON cs.city_id = s.student_city_id
INNER JOIN
customers c ON c.customer_id = s.student_customer_id
INNER JOIN
price_to_course_number ptcn ON ptcn.ptcn_course_number = sd.student_course_number
INNER JOIN
pricegroups pg ON pg.price_id = ptcn.ptcn_price_id
WHERE
('2012-10-01' OR '2012-10-31' BETWEEN sd.student_startdate AND sd.student_enddate)
AND cs.city_id = '12'
AND sd.student_course_number = '46248'
ORDER BY s.student_lastname ASC
这将打印以下行(编辑掉不必要的列):
+------------+--------------------+-----------------+
| student_id | student_startdate | student_enddate |
+------------+--------------------+-----------------+
| 299 | 2012-09-24 | 2012-10-21 |
| 299 | 2012-09-17 | 2012-09-23 |
+------------+--------------------+-----------------+
在我的查询中注意我有WHERE ('2012-10-01' OR '2012-10-31' BETWEEN sd.student_startdate AND sd.student_enddate)
为什么我会得到这个结果?
| 299 | 2012-09-17 | 2012-09-23 |