mysql - How to select a row inserted before another row, timestamp? -


say have:

 -------------------------------------- | item   | value | timestamp           |  -------------------------------------- | apple  | red   | 2013-04-15 09:34:44 | | orange | orange| 2014-04-15 09:34:44 | | banana | yellow| 2015-04-15 09:34:44 | | fruit  | mix   | 2016-04-15 09:34:44 | | malon  | red   | 2017-04-15 09:34:44 | ---------------------------------------- 

question: select 1 row inserted before specific timestamp

i tried:

select *    table   timestamp < '2015-04-15 09:34:44'   limit 1     , item not null 

the row want select row insert before date 2015-04-15 09:34:44 2014-04-15 09:34:44. above query used selected rows inserted before date 2015-04-15 09:34:44 , tried limit 1 output result 2013-04-15 09:34:44 oldest one.

try this:

select *  `table`  `timestamp` < '2015-04-15 09:34:44' , not `item` null order `timestamp` desc limit 1 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -