On Thu, Nov 21, 2013 at 2:31 PM, desmodemone <desmodemone(at)gmail(dot)com> wrote:
> Hi Robert, could you try with "exists" ?
>
> SELECT c.*
> FROM contacts c
> WHERE exists ( SELECT 1 FROM phone p WHERE p.addr =? and
> p.contact_id=c.id )
> OR exists (SELECT 1 FROM email e WHERE e.addr = ? and e.contact_id=c.id );
hm, how about:
SELECT c.*
FROM contacts c
WHERE exists (
SELECT 1
FROM phone p
WHERE p.addr =? AND p.contact_id=c.id
UNION ALL
SELECT 1 FROM email e
WHERE e.addr = ? AND e.contact_id=c.id
);
merlin