Hi again,
MySQL ver 4.0.25
Having sorted out a calendar search with the help of this forum, I am now working on using the same table to show a price list.
My table with a portion of data is this:
tbl_availability
----------------------------------------------
id(int11) | ddate(date) | price(int4)
----------------------------------------------
45 | 2006-01-01 | 250
45 | 2006-01-02 | 250
45 | 2006-01-03 | 250
45 | 2006-01-04 | 300
45 | 2006-01-05 | 300
45 | 2006-01-06 | 300
45 | 2006-01-07 | 300
45 | 2006-01-08 | 300
45 | 2006-01-09 | 500
45 | 2006-01-10 | 500
45 | 2006-01-11 | 500
45 | 2006-01-12 | 500
45 | 2006-01-13 | 500
45 | 2006-01-14 | 500
45 | 2006-01-15 | 300
45 | 2006-01-16 | 300
45 | 2006-01-17 | 300
45 | 2006-01-18 | 300
So far I have got stuck at:
SELECT min(ddate) as datefrom, max(ddate) as dateto, price FROM tbl_availability WHERE property_id=45 GROUP BY price ORDER BY datefrom
Returning the following:
date from 2006-01-01 - dateto 2006-01-03 - price 250
date from 2006-01-04 - dateto 2006-01-18 - price 300
date from 2006-01-09 - dateto 2006-01-14 - price 500
Whereas a correct price list would show:
date from 2006-01-01 - dateto 2006-01-03 - price 250
date from 2006-01-04 - dateto 2006-01-08 - price 300
date from 2006-01-09 - dateto 2006-01-14 - price 500
date from 2006-01-15 - dateto 2006-01-18 - price 300
Please could someone show me how to proceed from the above query to return the second resultset?








Bookmarks