I have 2 tables:
- customers (customer_id, customer_name)
- documents (document_id, document_name, customer_id)
I wish to find all customers, for example, that do not have a rent contract.
I can do it such way:
SELECT contragent_name
FROM contragents
WHERE contragent_id NOT IN (SELECT contragent_id
FROM documents
WHERE document_name = 'Rent contract');
Can anybody suggest how to do it without the second select?