You can filter on rows whose first column is equal to or less than the parameter, order by descending value in that column, and keep the top row only, using limit.

Assuming that the filtering column is called id:

select *
from mytable
where id <= ?
order by id desc
limit 1

The question mark represents the parameter to the query.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top