> Now, I want to find all objects that have at most properties 1,2,3, say (so > something with (1,2) is okay, as is (1,2,3)). I can't see a way to do this
> -- can anyone help?

It sounds like you are trying to find all objects that do not have any
properties outside of a specific list. One way to get that list is:

That's exactly right.


SELECT a_id
  FROM a
    WHERE
      NOT EXISTS
        (SELECT 1
          FROM b
          WHERE
            b.a_id = a.a_id
            AND
            b.property NOT IN (1, 2, 3)
        )
;

Yupp, this appears to do it! The 'double negation' is very clever.

Thanks a lot,
DL



---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

              http://www.postgresql.org/docs/faq

Reply via email to