Background...
I'm trying to query the database to see what rental properties we have available in a given date range. The storage method is horrible, but it's being created by a desktop program :/ The website is written in Wordpress, but I can't even get the correct results even when I manually query the database.
The Problem...
There are 3 columns in the database: propid, av_date and avail. I have a property that is booked on May 31st and June 8th, but available every day between. When I view the data in the table, it looks like this:
propid av_date avail
1051 2013-05-31 U
1051 2013-06-01 A
1051 2013-06-02 A
1051 2013-06-03 A
1051 2013-06-04 A
1051 2013-06-05 A
1051 2013-06-06 A
1051 2013-06-07 A
1051 2013-06-08 U
When I run the following query, the property is still showing up...
SELECT DISTINCT propid
FROM availabilities
WHERE avail = 'A'
AND av_date IN ('2013-05-31', '2013-06-01', '2013-06-02', '2013-06-03', '2013-06-04', '2013-06-05', '2013-06-06', '2013-06-07', '2013-06-08');
I've been beating my head against the wall for 2 days over this, so it's probably something stupid, but any help would be greatly appreciated!
avail = 'A'andav_dateis in the list of dates. For your sample data, that happens to be all the rows withavail = 'A'. What result do you want?