(This question may seem easy or kind of noobish, by that I pardon my ignorance.)
I used PDO query to use SELECT then fetch some values, it comes to a point that I need to fetch only some entries that within its start date and end date.
My database
+----------+-----------------+----------------------+--------------------+
| id (INT) | title (VARCHAR) | start_date (VARCHAR) | end_date (VARCHAR) |
+----------+-----------------+----------------------+--------------------+
| 1 | buddy | 2012-11-26 | 2012-11-30 |
| 2 | metro | 2012-12-05 | 2012-12-20 |
| 3 | justin | 2012-11-28 | 2012-12-01 |
+----------+-----------------+----------------------+--------------------+
My query is as follows:
$query = "SELECT title, start_date, end_date FROM debts WHERE start_date >= CURDATE() AND end_date >= CURDATE()";
What I want to achieve is whenever the start_date is today or greater but not exceeding the end_date it will be valid. This will return the row for id 1, however if I change the start_date to 2012-11-25, it will fail due to the first condition on AND. I'm really confuse on this since I am new to this, is there any built-in function to handle this kind of situation?