Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 4698F1337B34 for ; Tue, 22 Feb 2011 12:39:26 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 06684-06 for ; Tue, 22 Feb 2011 16:39:18 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 47397133740B for ; Tue, 22 Feb 2011 12:39:18 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p1MGdHYY001337; Tue, 22 Feb 2011 11:39:17 -0500 (EST) To: Andreas Gaab cc: pgsql sql Subject: Re: replace_matches does not return {null} In-reply-to: <48DA836F3865C54B8FBF424A3B775AF6671A68395D@Exchange-Server> References: <48DA836F3865C54B8FBF424A3B775AF6671A68395D@Exchange-Server> Comments: In-reply-to Andreas Gaab message dated "Tue, 22 Feb 2011 12:25:03 +0100" Date: Tue, 22 Feb 2011 11:39:17 -0500 Message-ID: <1336.1298392757@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201102/107 X-Sequence-Number: 35183 Andreas Gaab 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