Re: PostgreSQL equivelant of this MySQL query - Mailing list pgsql-general

From Madison Kelly
Subject Re: PostgreSQL equivelant of this MySQL query
Date
Msg-id 46982F2C.5070505@alteeve.com
Whole thread Raw
In response to PostgreSQL equivelant of this MySQL query  (Madison Kelly <linux@alteeve.com>)
List pgsql-general
Madison Kelly wrote:
> Hi all,
>
>   I am reading through some docs on switching to Postfix with a SQL
> backend. The docs use MySQL but I want to use PgSQL so I am trying to
> adapt as I go. I am stuck though; can anyone help give me the PgSQL
> equiv. of:
>
> SELECT
> CONCAT(SUBSTRING_INDEX(usr_email,'@',-1),'/',SUBSTRING_INDEX(usr_email,'@',1),'/')
> FROM users WHERE usr_id=1;
>
>   If the 'usr_email' value is 'person@domain.com' this should return
> 'domain.com/person'.
>
>   Thanks for the help!
>
> Madison

Bah, answered my own question after posting. :)

For the record:

SELECT substring(usr_email FROM '@(.*)')||'/'||substring(usr_email FROM
'(.*)@') FROM users WHERE usr_id=1;

Sorry for the line noise!

Madi

pgsql-general by date:

Previous
From: Madison Kelly
Date:
Subject: PostgreSQL equivelant of this MySQL query
Next
From: Steve Atkins
Date:
Subject: Re: PostgreSQL equivelant of this MySQL query