pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedRemoving simliar elements from a set
3+ messages / 2 participants
[nested] [flat]
* Removing simliar elements from a set
@ 2003-09-26 23:47 Dan Langille <dan@langille.org>
0 siblings, 2 replies; 3+ messages in thread
From: Dan Langille @ 2003-09-26 23:47 UTC (permalink / raw)
To: pgsql-sql
Hi folks,
I'm trying to remove items from a set which are similar to items in
another set.
This is the set (MASTER) from which I wish to remove items:
/ports/Mk/bsd.python.mk
/ports/lang/python-doc-html/distinfo
/ports/lang/python/Makefile
/ports/lang/python/distinfo
/ports/lang/python/files/patch-Modules-Setup.dist
These are the items (MATCHES) which are the prefixes which must be
removed:
/ports/lang/python-doc-html
/ports/lang/python
In this case, the answer would be:
/ports/Mk/bsd.python.mk
In short, we remove all items from MASTER which are under the directories
specified in MATCHES.
My first attempt, which works only if MATCHES contains one item:
SELECT *
FROM MASTER JOIN MATCHES
ON NOT (MASTER.pathname ~ ('^' || MATCHES.pathname || '/.+'));
However, if there is more than one row in MATCHES, this will not work.
Clues please?
--
Dan Langille - http://www.langille.org/
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Removing simliar elements from a set
@ 2003-09-26 23:55 Josh Berkus <josh@agliodbs.com>
parent: Dan Langille <dan@langille.org>
1 sibling, 0 replies; 3+ messages in thread
From: Josh Berkus @ 2003-09-26 23:55 UTC (permalink / raw)
To: Dan Langille <dan@langille.org>; pgsql-sql
Dan,
> I'm trying to remove items from a set which are similar to items in
> another set.
<snip>
> In short, we remove all items from MASTER which are under the directories
> specified in MATCHES.
from your example, you are trying to remove all directories which do *not*
match. What do you want, exactly?
--
-Josh Berkus
Aglio Database Solutions
San Francisco
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Removing simliar elements from a set
@ 2003-09-27 12:38 Dan Langille <dan@langille.org>
parent: Dan Langille <dan@langille.org>
1 sibling, 0 replies; 3+ messages in thread
From: Dan Langille @ 2003-09-27 12:38 UTC (permalink / raw)
To: Josh Berkus <josh@agliodbs.com>; +Cc: pgsql-sql
On 26 Sep 2003 at 16:55, Josh Berkus wrote:
> Dan,
>
> > I'm trying to remove items from a set which are similar to items in
> > another set.
> <snip>
>
> > In short, we remove all items from MASTER which are under the directories
> > specified in MATCHES.
>
> from your example, you are trying to remove all directories which do *not*
> match. What do you want, exactly?
Josh and I talked on IRC about this.
This is the result set I want:
/ports/Mk/bsd.python.mk
I want things from MASTER which do not match things in MATCHES.
Josh suggested this:
SELECT *
FROM master
WHERE NOT EXISTS (
SELECT *
FROM matches
WHERE master.pathname LIKE (matches.pathname || '/%'));
Cheers.
--
Dan Langille : http://www.langille.org/
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2003-09-27 12:38 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-09-26 23:47 Removing simliar elements from a set Dan Langille <dan@langille.org>
2003-09-26 23:55 ` Josh Berkus <josh@agliodbs.com>
2003-09-27 12:38 ` Dan Langille <dan@langille.org>
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