Re: MySQL insert() and instr() equiv

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: MySQL insert() and instr() equiv
Дата
Msg-id 15857.1150562017@sss.pgh.pa.us
обсуждение исходный текст
Ответ на MySQL insert() and instr() equiv  (Mark Constable <markc@renta.net>)
Ответы Re: MySQL insert() and instr() equiv  (Mark Constable <markc@renta.net>)
Список pgsql-general
Mark Constable <markc@renta.net> writes:
> uid is an email address stored in the passwd table as user@domain.com
> and this construct allows an incoming username such as "user.domain.com"
> to be compared to the stored "user@domain.com".
> SELECT wpath FROM passwd WHERE uid="\L" OR insert(uid,instr(uid,'@'),1,'.')="\L"

Well, if you want to write it exactly that way you'd need to write
insert() and instr() functions, which would probably take about five
minutes in any reasonably decent string-mashing language such as plperl.
You could do it in plpgsql but it'd be more painful.  (There's an
example of coding instr() in the back of the plpgsql manual chapter,
but it's intended to match Oracle's version of instr() which might not
be quite like MySQL's.)

But, if you're not wedded to that particular way, why not use replace()?

SELECT wpath FROM passwd WHERE uid="\L" OR replace(uid, '@', '.')="\L"

            regards, tom lane

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

Предыдущее
От: Mark Constable
Дата:
Сообщение: MySQL insert() and instr() equiv
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: MySQL insert() and instr() equiv