From: | Andreas Kretschmer <akretschmer(at)despammed(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: [despammed] How do I do this? |
Date: | 2005-03-23 18:52:35 |
Message-ID: | 20050323185235.GC1271@webserv.wug-glas.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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 ===
From | Date | Subject | |
---|---|---|---|
Next Message | bandeng | 2005-03-23 20:53:33 | Re: view function on pg_toast |
Previous Message | Michael Long | 2005-03-23 17:59:45 | Re: best way to swap two records (computer details) |