I have this long and nasty MySQL query:
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
This will print the following lines (edited out unnecessary columns):
+------------+--------------------+-----------------+
| student_id | student_startdate | student_enddate |
+------------+--------------------+-----------------+
| 299 | 2012-09-24 | 2012-10-21 |
| 299 | 2012-09-17 | 2012-09-23 |
+------------+--------------------+-----------------+
Notice in my query I have WHERE ('2012-10-01' OR '2012-10-31' BETWEEN sd.student_startdate AND sd.student_enddate)
Why do I get this as a result?
| 299 | 2012-09-17 | 2012-09-23 |