CREATE TABLE IF NOT EXISTS `debtor_weeksdate` (
`wID` int(1) NOT NULL AUTO_INCREMENT,
`money_id` mediumint(1) NOT NULL,
`debtor_id` mediumint(1) NOT NULL,
`creditor_id` mediumint(11) NOT NULL,
`wDate` varchar(11) NOT NULL,
PRIMARY KEY (`wID`),
UNIQUE KEY `wID` (`wID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=122 ;
--
-- Dumping data for table `debtor_weeksdate`
--
INSERT INTO `debtor_weeksdate` (`wID`, `money_id`, `debtor_id`, `creditor_id`, `wDate`) VALUES
(29, 68, 19, 457456, 'Jan 13,2014'),
(30, 68, 19, 457456, 'Jan 20,2014'),
(85, 60, 5, 457456, 'Jan 27,2014'),
(87, 96, 35, 457456, 'Jan 28,2014'),
(92, 60, 5, 457456, 'Feb 03,2014'),
(93, 68, 19, 457456, 'Feb 03,2014'),
(98, 60, 5, 457456, 'Feb 10,2014'),
(99, 68, 19, 457456, 'Feb 10,2014'),
(105, 60, 5, 457456, 'Feb 17,2014'),
(121, 104, 10, 457456, 'Feb 25,2014');
So this is the real deal.
[ol][li] I run a query looking for the first money_id that was inserted only that 1 record, that is why LIMIT and ASC are used.[/li]
[li]There might be a chance that money_id is not found so result will not be 1, it will be 0[/li]
[li]So depending on nums of rows I run different blocks of codes, found record will always be either 1 or 0[/li][/ol]