I'm storing recurring events in an events table that take place during certain months of the year, any year and every year. For instance;
CREATE TABLE events (
event_id tinyint(3) unsigned NOT NULL auto_increment,
name varchar(255) NOT NULL,
month_from tinyint(3) unsigned NOT NULL,
month_to tinyint(3) unsigned NOT NULL,
PRIMARY KEY (event_id) )
ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3;
INSERT INTO events
(event_id, name, month_from, month_to)
VALUES
(1, 'Event ABC', 5, 11), (2, 'Event XYZ', 12, 4);
Event ABC - takes place every year during May - Nov and Event XYZ - takes place every year during Dec - Apr
In my events table I'm storing the month_from
and month_to
as numeric values.
What I want to be able to do is say take the current month (Oct) and pass it into an sql query for it to return to me the correct event "Event ABC". But also I want to pass to it a future month of say Feb it should return to me "Event XYZ"
I hope that makes sense?