> I have 2 tables:
>
> bases, and properties
>
> base has a ZIPCODE field in the table, as does the properties table.
>
> I'm trying to find all bases that do NOT have a property in that zip code.
>
> What I've tried is:

The general answer:
http://www.bitbybit.dk/mysqlfaq/faq.html#ch7_10_0

In your case, it comes out to something like:

SELECT cb.*, cp.*
FROM classified_bases AS cb
  LEFT JOIN classified_properties AS cp
    ON cb.ZIP = cp.ZIPCODE
WHERE cp.ZIPCODE IS NULL
  AND cb.BASEORLOC = 'B'
  AND cb.STATE = 'VA'
  AND cb.STATE = cp.STATE;

/ Carsten
--
Carsten H. Pedersen
keeper and maintainer of the bitbybit.dk MySQL FAQ
http://www.bitbybit.dk/mysqlfaq




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to