pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHow do I do this?
3+ messages / 3 participants
[nested] [flat]
* How do I do this?
@ 2005-03-23 17:37 Wei Weng <wweng@kencast.com>
2005-03-23 18:52 ` Re: [despammed] How do I do this? Andreas Kretschmer <akretschmer@despammed.com>
2005-03-24 01:34 ` Re: How do I do this? Greg Sabino Mullane <greg@turnstep.com>
0 siblings, 2 replies; 3+ messages in thread
From: Wei Weng @ 2005-03-23 17:37 UTC (permalink / raw)
To: pgsql-sql
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
as the result of a query?
Thanks!
(I am using PostgreSQL 7.4)
Wei
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [despammed] How do I do this?
2005-03-23 17:37 How do I do this? Wei Weng <wweng@kencast.com>
@ 2005-03-23 18:52 ` Andreas Kretschmer <akretschmer@despammed.com>
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Kretschmer @ 2005-03-23 18:52 UTC (permalink / raw)
To: 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 ===
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: How do I do this?
2005-03-23 17:37 How do I do this? Wei Weng <wweng@kencast.com>
@ 2005-03-24 01:34 ` Greg Sabino Mullane <greg@turnstep.com>
1 sibling, 0 replies; 3+ messages in thread
From: Greg Sabino Mullane @ 2005-03-24 01:34 UTC (permalink / raw)
To: pgsql-sql
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> I have a table with column filepath with contents that look like the following:
..
> Is there anyway to retrieve the directory information only regarding those
> filepaths?
SELECT rtrim(substring(filepath from '.+/'),'/') FROM mytable;
- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200503232033
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----
iD8DBQFCQhkMvJuQZxSWSsgRAjTaAJ9zmgSOBH/Nre/XMw+JajBni8YyDwCg1DyV
Cd5rIhi026KFoFZEFjMOYvI=
=V9ov
-----END PGP SIGNATURE-----
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2005-03-24 01:34 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-03-23 17:37 How do I do this? Wei Weng <wweng@kencast.com>
2005-03-23 18:52 ` Andreas Kretschmer <akretschmer@despammed.com>
2005-03-24 01:34 ` Greg Sabino Mullane <greg@turnstep.com>
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