From: | Clark Evans <clark(dot)evans(at)manhattanproject(dot)com> |
---|---|
To: | mlemos(at)acm(dot)org |
Cc: | Ulf Mehlig <umehlig(at)uni-bremen(dot)de>, pgsql-general(at)postgreSQL(dot)org |
Subject: | Re: [GENERAL] Negating the list of selected rows of a join |
Date: | 1999-03-14 08:21:13 |
Message-ID: | 36EB7179.206BD7CB@manhattanproject.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Manuel Lemos wrote:
>
> I want to list the rows of a table with a text field whose values do not
> exist in a similar field of another table. Basically what I want to get
> is negated results of a join.
Ulf Mehlig wrote:
> SELECT name FROM table_a
> WHERE name NOT IN (SELECT name FROM table_b);
Clark Evans wrote:
> SELECT table_a.name, table_a.age
> FROM table_a
> WHERE NOT EXISTS (
> SELECT 'x'
> FROM table_b
> WHERE table_b.name = table_a.name
> );
I'm not sure about how well PostgreSQL handles
these two. I'd try them both with your data set.
If table_b is small (less than a few thousand rows)
then Ulf's approach would work best. However,
if table_b is large (more than a thousand)
then I think the other approach may work better
if table_b.name is indexed.
Clark
From | Date | Subject | |
---|---|---|---|
Next Message | Ulf Mehlig | 1999-03-14 09:26:00 | Re: [GENERAL] Negating the list of selected rows of a join |
Previous Message | Ulf Mehlig | 1999-03-14 08:17:20 | Re: [GENERAL] Negating the list of selected rows of a join |