Hi, This is my first time posting here so hope I'm in the right place. I'm looking to run a Custom Query to get all internal emails (i.e. where all recipients are internal). I've written the following query but it isn't yielding any results - does anyone know what I might be doing wrong?
select * from emails e
inner join emails_text et on e.id=et.email_id
inner join emails_email_addr_rel er on e.id=er.email_id
inner join email_addresses ea on er.email_address_id = ea.id
where e.id not in
(select distinct email_id from emails_email_addr_rel emr
inner join email_addresses ema on emr.email_address_id=ema.id
where email_address not like '%@myorganisation.org%')