pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dan Langille <dan@langille.org>
To: pgsql-sql@postgresql.org
Subject: Removing simliar elements from a set
Date: Fri, 26 Sep 2003 19:47:06 -0400 (EDT)
Message-ID: <20030926184440.B301@laptop.unixathome.org> (raw)

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/



view thread (3+ messages)  latest in thread

Message-ID: <20030926184440.B301@laptop.unixathome.org>
Permalink:  ../20030926184440.B301@laptop.unixathome.org/
Also on:    postgresql.org/message-id/20030926184440.B301@laptop.unixathome.org

 · 

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: dan@langille.org
  Subject: Re: Removing simliar elements from a set
  In-Reply-To: <20030926184440.B301@laptop.unixathome.org>

* 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