> SELECT * FROM camps where id in (SELECT DISTINCT camp_id FROM application);
Computing the DISTINCT portion here may be superfluous, and possibly (depending on your DB) a premature mis-optimization. Whether DISTINCT or not, membership via IN will still behave the same, but DISTINCT will require a pass to determine distinct-ness. Without the DISTINCT keyword, the DB should be able to just do a hash-lookup for each ID in its Camps set to test membership. Or, alternatively, one could do something like SELECT c.* FROM camps c INNER JOIN application a ON c.id = a.camp_id which might also be another way to let the optimizer take a crack at doing it well. YMMV, so be sure to use your DB's EXPLAIN abilities to disclose the nitty-gritty details and choose what works best. -tim --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---