pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Kretschmer <akretschmer@despammed.com>
To: pgsql-sql@postgresql.org
Subject: Re: [despammed] How do I do this?
Date: Wed, 23 Mar 2005 19:52:35 +0100
Message-ID: <20050323185235.GC1271@webserv.wug-glas.de> (raw)
In-Reply-To: <4241A972.6040103@kencast.com>
References: <4241A972.6040103@kencast.com>

am  23.03.2005, um 12:37:54 -0500 mailte Wei Weng folgendes:
> I have a table with column filepath with contents that look like the 
> following:
> 
> filepath
> ==============
> /var/log/foo
> /var/log/bar
> /var/cache/foo
> /var/cache/bar
> /var/foo
> /var/bar
> 
> Is there anyway to retrieve the directory information only regarding those 
> filepaths?
> 
> So that I can get
> 
> /var/log
> /var/cache
> /var
> 

test_db=# select * from filepath ;
      path
----------------
 /var/log/foo
 /var/log/bar
 /var/cache/foo
 /var/cache/bar
 /var/foo
(5 Zeilen)

test_db=# select substring (path, '/.*/') from filepath ;
  substring
-------------
 /var/log/
 /var/log/
 /var/cache/
 /var/cache/
 /var/
(5 Zeilen)


test_db=# select trim(trailing '/'from substring (path, '/.*/')) from filepath ;
   rtrim
------------
 /var/log
 /var/log
 /var/cache
 /var/cache
 /var
(5 Zeilen)




test_db=# select version();
                                               version
------------------------------------------------------------------------------------------------------
 PostgreSQL 7.4.7 on i386-pc-linux-gnu, compiled by GCC i386-linux-gcc (GCC) 3.3.5 (Debian 1:3.3.5-5)
(1 Zeile)


Regards, Andreas
-- 
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47212,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    === 



view thread (3+ messages)  latest in thread

Message-ID: <20050323185235.GC1271@webserv.wug-glas.de>
Permalink:  ../20050323185235.GC1271@webserv.wug-glas.de/
Also on:    postgresql.org/message-id/20050323185235.GC1271@webserv.wug-glas.de

 · 

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: akretschmer@despammed.com
  Subject: Re: [despammed] How do I do this?
  In-Reply-To: <20050323185235.GC1271@webserv.wug-glas.de>

* 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