Re: How to FindNearest
От | Bruno Wolff III |
---|---|
Тема | Re: How to FindNearest |
Дата | |
Msg-id | 20061003002049.GA1490@wolff.to обсуждение исходный текст |
Ответ на | How to FindNearest ("Alexander Ilyin" <a_ilyin@ukr.net>) |
Ответы |
Re: How to FindNearest
|
Список | pgsql-sql |
On Sat, Sep 30, 2006 at 11:43:40 +0300, Alexander Ilyin <a_ilyin@ukr.net> wrote: > > Suppose we have huge table. On the screen we need to show contents of that table in the Grid and under that Grid user caninput in TextBox some letters. OnChange of this TextBox we need to make current row selection in the Grid on the row withvalue of some column nearest to the user input in the TextBox. > > How this can be implemented in PostgreSQL? You can search for the row with the closest above and the row with the closest below and then return whichever these is closer. (Remember to handle the case where the target is larger or smaller than all values in the database.) You can use ORDER BY and LIMIT 1 and an appropiiate WHERE clause (something like columnname >= targetvalue) to do this.
В списке pgsql-sql по дате отправления: