mysql - Excluding everything above denormalized date in query -
i denormalized data (so date split in year, month, day , hour column) wonder how query before date.
this not work:
select * `impression_stat_hour` doneforday =0 , ( year <=2011 , month <=6 , day <=30 , hour <=1 )
this won't "group" records want them too, resulting in date (for example) hour 0 , hour 1.
select ... year < 2011 or (year = 2011 , month < 6) or (year = 2011 , month = 6 , day < 30) or (year = 2011 , month = 6 , day = 30 , hour <= 1)
or:
select ... str_to_date(concat(year,'-',month,'-',day,' ',hour,':00:00')) <= '2011-06-30 01:00:00';
the latter lot slower (since can't use indexes on various date columns. it's untested, since (ancient) version of mysql have access doesn't support str_to_date().
Comments
Post a Comment