I am new to this after spending 2 days trying to find an answer on the net
I am trying to construct a MYSQL select statement
I have 2 tables on ethat contains a list of dates and prices, the second is a table of reservation dates with start and end. I am tring to show al the FREE dates & prices in Table 1 that DO NOT exist in any of the reservation records in Table 2
Table 1 called – dates_prices –
id, date, price
example data
333, 2011-12-20, 66.00
333, 2011-12-21, 66.00
333, 2011-12-22, 66.00
333, 2011-12-23, 66.00
333, 2011-12-24, 66.00
333, 2011-12-25, 66.00
333, 2011-12-26, 66.00
333, 2011-12-27, 66.00
333, 2011-12-28, 66.00
333, 2011-12-29, 66.00
333, 2011-12-30, 66.00
Table 2 – reservations
id, startdate, enddate
example data
333, 2011-12-20, 2011-12-22
333, 2011-12-24, 2011-12-26
333, 2011-12-28, 2011-12-30
I need to extract ONLY the dates from Table 1 that do not exist in the Table 2 records between start and end dates of all records in table 2 with the same ID number 333
So the only records that should be displayed from table 1 are as follows
id, date, price
333, 2011-12-23, 66.00
333, 2011-12-27, 66.00
333, 2011-12-31, 66.00
try this after creating above tables. solution to ur probelm is u need to make this type of query to tables ie
select * from table12 where datefor not between ‘2011-12-20’ and ‘2011-12-22’ and datefor not between ‘2011-12-24’ and ‘2011-12-26’ and datefor not between ‘2011-12-28’ and ‘2011-12-30’ and table12.id=333 i have made one proc just u need to pass ur id.