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