I have a table with the following data:
Code:
id | people_id | start_date | end_date
---+-----------+------------+----------
1 | 27 | 10/01/2010 | 10/07/2010
2 | 27 | 10/09/2010 | 10/12/2010
3 | 27 | 11/03/2010 | 11/05/2010
What I'm trying to do is compare a user-entered date between the dates in the start_date and end_date columns. For example, if the user enters '10/03/2010', I want to be able to detect that the date already exists between the two columns, per row, just so I can detect duplicate entries.
I have this right now:
Code:
SELECT * FROM unavailability WHERE start_date >= '". format_date_db($start_date) ."' OR end_date <= '". format_date_db($start_date) ."' AND people_id = '$people_id'
but, I think this is checking all the columns, but not necessarily at the "row" level. Is there a way I can check dates that are between each date in each column per row? Thanks!