i have a table in database , and i want write query code to select collective date between two record .
this is sample code :
table is :
CREATE TABLE `user` (
`userid` int(11) NOT NULL AUTO_INCREMENT,
`startdate` date NOT NULL,
`enddate` date NOT NULL,
PRIMARY KEY (`userid`)
)
example 1 and i have 2 record in table .
(userid =>1 , startdate => '2012-02-02' , enddate => '2012-10-02') (userid =>2 , startdate => '2012-04-02' , enddate => '2012-09-02')
i want select query to give range '2012-04-02' until '2012-09-02'
example 2 and i have 2 record in table .
(userid =>1 , startdate => '2012-02-02' , enddate => '2012-02-12') (userid =>2 , startdate => '2012-04-02' , enddate => '2012-09-02')
i want select query to give null range
is there best query for this?