mysql - Re-selecting from a table based on query results -


my sql knowledge basic , grateful advice. have table columns like:

date, time, readings, .... comments1, comments2

what filter table show results when comments1 equal string, can achieve. tricky bit want find readings when time between 5 , 7 hours after times returned/identified initial query (comments1 = string"). there way , best strategy?

thank you.

you should store date , time in single column, otherwise midnight boundaries extremely difficult select across. example assumes "date" column datetime type stores timestamp.

i believe you're looking for:

with commenttime (     select top 1 date     tblrecords     comments1 = 'the comment find' ) select * tblrecords date >= dateadd(hour, 5, (select date commenttime))   , date < dateadd(hour, 7, (select date commenttime)) 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -