Removing simliar elements from a set

From: Dan Langille <dan(at)langille(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: Removing simliar elements from a set
Date: 2003-09-26 23:47:06
Message-ID: 20030926184440.B301@laptop.unixathome.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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/

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2003-09-26 23:55:13 Re: Removing simliar elements from a set
Previous Message Tom Lane 2003-09-26 22:53:06 Re: [HACKERS] plpgsql doesn't coerce boolean expressions to boolean