Search Postgresql Archives

Re: MySQL insert() and instr() equiv

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mark Constable <markc@xxxxxxxxx> writes:
> uid is an email address stored in the passwd table as user@xxxxxxxxxx
> and this construct allows an incoming username such as "user.domain.com"
> to be compared to the stored "user@xxxxxxxxxx".
> 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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux