agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Ertan Küçükoğlu <ertan.kucukoglu@1nar.com.tr>
Cc: pgsql-sql <pgsql-sql@lists.postgresql.org>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Subject: Re: Converting from MySQL
Date: Wed, 23 Jan 2019 06:38:55 +0000
Message-ID: <87k1iv3n3k.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <CAKFQuwayxz1DJcvaTccXzRYPZaU3geMV-7TBAZFL3NXHDAkE8g@mail.gmail.com>
References: <000101d4b298$61f471d0$25dd5570$@1nar.com.tr>
	<CAKFQuwayxz1DJcvaTccXzRYPZaU3geMV-7TBAZFL3NXHDAkE8g@mail.gmail.com>

 >> Failed to find PostgreSQL equivalent for below one because I did not
 >> understand what it does in the first place.
 >> 
 >> SELECT
 >> CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/')
 >> FROM users WHERE email='%s'

It looks to me like this would work as well or better in PG:

select regexp_replace(email, '^(.*)@(.*)$', '\2/\1/') from ...

-- 
Andrew (irc:RhodiumToad)




view thread (3+ messages)

Message-ID: <87k1iv3n3k.fsf@news-spur.riddles.org.uk>
Permalink:  ../87k1iv3n3k.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87k1iv3n3k.fsf@news-spur.riddles.org.uk

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, ertan.kucukoglu@1nar.com.tr, pgsql-sql@lists.postgresql.org, david.g.johnston@gmail.com
  Subject: Re: Converting from MySQL
  In-Reply-To: <87k1iv3n3k.fsf@news-spur.riddles.org.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox