Re: replace_matches does not return {null} - Mailing list pgsql-sql

From Tom Lane
Subject Re: replace_matches does not return {null}
Date
Msg-id 1336.1298392757@sss.pgh.pa.us
Whole thread Raw
In response to replace_matches does not return {null}  (Andreas Gaab <A.Gaab@scanlab.de>)
List pgsql-sql
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
amloosing 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


pgsql-sql by date:

Previous
From: Andreas Gaab
Date:
Subject: replace_matches does not return {null}
Next
From: arthur_info
Date:
Subject: Re: Retrieve the column values of a record without knowing the names