Comparing the results of two sub-queries
I need to import data from a database. The contacts are linked to companies in two ways : _via_ contact informations, or _via_ an "activity". I need to get some lists.

The list of contacts without companies is easy enough :

    where idcontact not in (select idcontact from tb_contact_soc where idcontact is not null)
    and idcontact not in (select idcontact from tb_activite_soc_contact where idcontact is not null)

The list of contacts with multiple companies is more tricky.  
idcontact is the id of the contact ; ident is the id of the company. Tb_contact_soc is the table that links via contact infos ; tb_activite_soc_contact is the table that links via activities.

    where
    (
        -- contacts linked via their contact informations
        idcontact in (
            select idcontact
            from tb_contact_soc
            where idcontact is not null and ident is not null
            group by idcontact
            having count(*) > 1
        )
        -- contacts linked via an activity
        or idcontact in (
            select idcontact
            from tb_activite_soc_contact
            where idcontact is not null and ident is not null
            group by idcontact
            having count(*) > 1
        )
    ) and (
        -- here goes the snipplet I can't figure out
    )

In the last "and", I need to say something like "where, for this contact, at least one of the companies from the tb_contact_soc table is not found in the companies from the tb_activite_soc_contact table". But I can't figure it out.

I only need to get it once, so our customer can validate the data before we launch the import, so it can be a bit convulted (not too much, thanks ;) )
Comparing the results of two sub-queries
===

I need to import data from a database. The contacts are linked to companies in two ways : _via_ contact informations, or _via_ an "activity". I need to get some lists.

The list of contacts without companies is easy enough :

    where idcontact not in (select idcontact from tb_contact_soc where idcontact is not null)
    and idcontact not in (select idcontact from tb_activite_soc_contact where idcontact is not null)

The list of contacts with multiple companies is more tricky.  
idcontact is the id of the contact ; ident is the id of the company. Tb_contact_soc is the table that links via contact infos ; tb_activite_soc_contact is the table that links via activities.

    where
    (
        -- contacts linked via their contact informations
        idcontact in (
            select idcontact
            from tb_contact_soc
            where idcontact is not null and ident is not null
            group by idcontact
            having count(*) > 1
        )
        -- contacts linked via an activity
        or idcontact in (
            select idcontact
            from tb_activite_soc_contact
            where idcontact is not null and ident is not null
            group by idcontact
            having count(*) > 1
        )
    ) and (
        -- here goes the snipplet I can't figure out
    )

In the last "and", I need to say something like "where, for this contact, at least one of the companies from the tb_contact_soc table is not found in the companies from the tb_activite_soc_contact table". But I can't figure it out.

I only need to get it once, so our customer can validate the data before we launch the import, so it can be a bit convulted (not too much, thanks ;) )