I have a column that has month and years as columns.. I need to select a range out of the columns.. they don't seem to work with 2 ranges.
Table
CREATE TABLE `sampletable` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`AccountId` int(11) unsigned NOT NULL,
`CampaignId` int(11) unsigned NOT NULL,
`CampaignName` varchar(115) NOT NULL DEFAULT '',
`Sent` int(11) unsigned NOT NULL,
`Month` int(11) unsigned NOT NULL,
`Year` int(11) unsigned NOT NULL,
`LocationId` int(11) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `AccountId_idx` (`AccountId`),
KEY `monthy_year_idx` (`Month`,`Year`),
KEY `locationid_idx` (`LocationId`)
) ENGINE=MyISAM AUTO_INCREMENT=1584
Select statement:
SELECT * FROM sampletable
WHERE AccountId = 1
and (`Month` >= 10 AND `Year` = 2012)
and (`Month` <= 2 AND `Year` = 2013)
ORDER BY Year asc, month asc
This does not seem to work.
Do I have to convert these into date formats and use between?