There is a query that combines two tables: sellers and buyers. The output is the name of the seller or buyer, the type (seller or buyer) and country. How now you can leave only those lines where a country is in the seller and the buyer? Those. if there are buyers from Russia, and there are no sellers from Russia, these lines should be excluded.

You can completely change the query, but not use the JOIN .

 SELECT CompanyName AS Person, 'Customer' AS Type, Country FROM Customers UNION SELECT CompanyName AS Person, 'Seller' AS Type, Country FROM Suppliers ORDER BY Country, Person 

    1 answer 1

     SELECT CompanyName AS Person, 'Customer' AS Type, Country FROM Customers where Country in (select distinct Country from Suppliers) UNION SELECT CompanyName AS Person, 'Seller' AS Type, Country FROM Suppliers where Country in (select distinct Country from Customers) ORDER BY Country, Person