| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Andreas Gaab <A(dot)Gaab(at)scanlab(dot)de> |
| Cc: | pgsql sql <pgsql-sql(at)postgresql(dot)org> |
| Subject: | Re: replace_matches does not return {null} |
| Date: | 2011-02-22 16:39:17 |
| Message-ID: | 1336.1298392757@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
Andreas Gaab <A(dot)Gaab(at)scanlab(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | arthur_info | 2011-02-22 19:39:01 | Re: Retrieve the column values of a record without knowing the names |
| Previous Message | Andreas Gaab | 2011-02-22 11:25:03 | replace_matches does not return {null} |