xorinzor
xorinzor

Reputation: 6477

how to select previous row based on date

I have a form where you can enter an date, now in my table i have these fields:

What I need is the previous record(/date) based on the given timestamp, I really have no idea on how to do this in MySQL.

Any help would be greatly appreciated!

Upvotes: 0

Views: 98

Answers (1)

socha23
socha23

Reputation: 10239

SELECT * FROM table WHERE timestamp < :myTimeStamp ORDER BY timestamp DESC LIMIT 0, 1

Upvotes: 1

Related Questions