SQLite Forum

Nearest-match join
Next before or equal and next after or equal for a single value is an easy correlated subquery.  Assuming that the tables have a single column primary key, simply generate a keyset using correlated subqueries, then use that keyset to retrieve your data.  It is going to be slow.