From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andreas Gaab <A.Gaab@scanlab.de>
Cc: pgsql sql <pgsql-sql@postgresql.org>
Subject: Re: replace_matches does not return {null}
Date: Tue, 22 Feb 2011 11:39:17 -0500
Message-ID: <1336.1298392757@sss.pgh.pa.us> (raw)
In-Reply-To: <48DA836F3865C54B8FBF424A3B775AF6671A68395D@Exchange-Server>
References: <48DA836F3865C54B8FBF424A3B775AF6671A68395D@Exchange-Server>
Andreas Gaab <A.Gaab@scanlab.de> writes:
> I tried to order a text-column only by parts of the entries. Therefore I used regexp_matches(), but unfortunately I am loosing rows.
> SELECT regexp_matches('abc','[0-9]+'), regexp_matches('123','[0-9]+');
> Does not return "{null}, {123}" but no result at all.
Yes, because regexp_matches returns a rowset of zero or more results.
The fine manual suggests putting it in a sub-select if what you want
is a null or a single result:
SELECT ... , (SELECT regexp_matches(...)) FROM ...
regards, tom lane
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: tgl@sss.pgh.pa.us, A.Gaab@scanlab.de
Subject: Re: replace_matches does not return {null}
In-Reply-To: <1336.1298392757@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox