I use MySQL for this.
(I remove unnecessary connections to make it a little clearer)
I try to select company addresses by grouping company_id, but exclude the entire user if they have addresses in a specific country (with ID 242)
So, the first request I tried was:
SELECT c.company_id FROM companies c NATURAL JOIN addresses a WHERE a.country_id != 15 GROUP BY c.company_id
From what I understand, it first selects select, then excludes the rows that have country_id from 15, and then returns the company_id of the remaining rows, which are different since they were grouped.
Thus, this returns any company that has at least one address outside of country 15. I need to exclude any company that has an address in this country.
How can i do this?
rca86 source share