mysql - Select data where have DateTime from some minute ago until now? -


i ask how query select data having datetime minute ago until ? ex : result data 5 minute ago (field: input_time) until ..

this query

select * operasi  timestamp(input_time) <= timestamp(now())  ,  order input_time desc limit 0,10 

you should query as:

select * operasi input_time <= now() ,       input_time >= date_sub(now(), interval 5 minute) order input_time desc limit 0, 10; 

this structure allow query take advantage of index on input_time. if wrap column in function, less likely.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -