mysql - SQL statement based on reccurrence -


one table has following data entries:

mm_id, mm_interval, mm_interval_type, mm_start_date, mm_start_hour, mm_end_hour 3,     14,          3,                2013-07-15,    08:22,         03:55 

mm_interval "every" mm_interval_type

array( 1=>"hour",  2=>"day",  3=>"week",  4=>"month",  5=>"year"  ) 

now, looking for, way select entries match current date.

/lars

i think alter question result soo far ;-)

select   mm.*,     mm_recurrence_settings.*     mm left join mm_types using (mm_type_id) left join mm_recurrence_settings using (mm_id)     select         case             when mm_recurrence_settings.mm_reoc_interval_type = 1 date(now()) between date(date_add(mm_recurrence_settings.mm_reoc_start_date, interval mm_recurrence_settings.mm_reoc_interval hour)) , curdate( )             when mm_recurrence_settings.mm_reoc_interval_type = 2 date(now()) between date(date_add(mm_recurrence_settings.mm_reoc_start_date, interval mm_recurrence_settings.mm_reoc_interval day)) , curdate( )             when mm_recurrence_settings.mm_reoc_interval_type = 3 date(now()) between date(date_add(mm_recurrence_settings.mm_reoc_start_date, interval mm_recurrence_settings.mm_reoc_interval week)) , curdate( )             when mm_recurrence_settings.mm_reoc_interval_type = 4 date(now()) between date(date_add(mm_recurrence_settings.mm_reoc_start_date, interval mm_recurrence_settings.mm_reoc_interval month)) , curdate( )             when mm_recurrence_settings.mm_reoc_interval_type = 5 date(now()) between date(date_add(mm_recurrence_settings.mm_reoc_start_date, interval mm_recurrence_settings.mm_reoc_interval year)) , curdate( )         end newdate 

this gets ....

my thought use between iterate on intervals me. alas, first iteration.

perhaps stored procedure or?


Comments