Show Companies with no MainContacts

I

iamnu

CoName Table has a CompanyName field.
Contacts Table has the name of a Contact, and a MainContact field (yes/
no).
So the SQL statement would include CompanyName, Contact and
MainContact.

I want to display (list) those CompanyNames which do not have a
MainContact.

How do I make this calculation?
 
M

Marshall Barton

iamnu said:
CoName Table has a CompanyName field.
Contacts Table has the name of a Contact, and a MainContact field (yes/
no).
So the SQL statement would include CompanyName, Contact and
MainContact.

I want to display (list) those CompanyNames which do not have a
MainContact.


Try using something like:

SELECT CompanyName
FROM CoName
WHERE Not Exist (SELECT 1
FROM Contacts
WHERE Contacts.CoID = CompanyName.CoID
And MainContact)
 
I

iamnu

Try using something like:

SELECT CompanyName
FROM CoName
WHERE Not Exist (SELECT 1
                                                                        FROM Contacts
                                                                        WHERE Contacts.CoID = CompanyName.CoID
                                                                                       And MainContact)

I'm getting a syntax error on "Not Exist". Did you mean something
else?
 
I

iamnu

iamnuwrote:


No, that's what I meant.  Post your query.

Here is my query...

SELECT CoNameID
FROM tblAddresses
WHERE Not Exist ((((SELECT 1
FROM tblContacts
WHERE tblAddresses.AddrID = tblContacts.AddrID And MainContact))
=False));
 
M

Marshall Barton

iamnu said:
SELECT CoNameID
FROM tblAddresses
WHERE Not Exist ((((SELECT 1
FROM tblContacts
WHERE tblAddresses.AddrID = tblContacts.AddrID And MainContact))
=False));


The parens are out of whack and the =False makes no sense.

If you can't get the query design view to generate SQL more
like what I posted, then skip the design view and do it all
in SQL view.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top