Re: Closes Match

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: Closes Match
Дата
Msg-id 20050725174952.GA23263@wolff.to
обсуждение исходный текст
Ответ на Closes Match  (Christian Rusa <christian@rusa.at>)
Ответы Re: Closes Match  ("Jonathan Lam" <lamj@spawar.navy.mil>)
REINDEX DATABASE  ("Eugene E." <sad@bankir.ru>)
Список pgsql-sql
On Mon, Jul 25, 2005 at 19:31:11 +0200, Christian Rusa <christian@rusa.at> wrote:
> Hi there,
> 
> I want to match a string against the database and get the closest 
> (shorter) match.
> I was asking myself if its possible to realise this in SQL.
> 
> So if the string is:
> abcdefg
> 
> And in the database are entries like:
> a
> ab
> abc
> 
> I just want to get back 'abc'.
> 
> I looked around in the internet and the documentation but found no solution.

You could ORDER BY the length of the strings descending and use LIMIT
to return only one row.

You can write a regular expression to do the matching. Something like:
^(a(b(c(d(e(fg?)?)?)?)?)?$


В списке pgsql-sql по дате отправления:

Предыдущее
От: Christian Rusa
Дата:
Сообщение: Closes Match
Следующее
От: "Jonathan Lam"
Дата:
Сообщение: Re: Closes Match