I am working on a foster care system and am working on making good data, I need to compare the admitted date and the end date between several records on the same child.
CREATE TABLE IF NOT EXISTS `cx_assignments` (
`ID` int(12) unsigned NOT NULL auto_increment,
`Children_ID` int(12) unsigned NOT NULL,
`StartDate` date NOT NULL,
`EndDate` date NOT NULL,
`Notes` text NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
--
-- Dumping data for table `cx_assignments`
--
INSERT INTO `cx_assignments` (`ID`, `Children_ID`, `StartDate`, `EndDate`, `Notes`) VALUES
(1, 1, '2010-01-01', '2010-02-05', ''),
(2, 1, '2010-02-06', '2010-05-04', ''),
(3, 1, '2010-05-04', '2010-06-05', ''),
(4, 2, '2010-03-10', '2010-05-04', ''),
(5, 2, '2010-10-24', '2010-12-18', ''),
(6, 3, '2010-01-01', '2010-12-31', ''),
(7, 4, '2010-12-20', '2010-12-21', ''),
(8, 4, '2010-01-24', '2010-02-15', ''),
(9, 4, '2010-03-20', '2010-05-04', ''),
(10, 4, '2010-12-31', '0000-00-00', ''),
(11, 1, '2010-06-06', '0000-00-00', ''),
(12, 2, '2010-12-31', '2010-01-01', '');
That is some example data, "Children_ID" corresponds to a child's record in another table.
I am so far as to know to join the table to itself, but I need some help as to methods of going through the records with only MySQL and returning the records that conflict with each others.
Also the "0000-00-00" are supposed to be infinity.
If anyone has any questions feel free to ask.