I want to list the country which border both ‘F’ and ‘D’.
Suppose we have
INSERT INTO borders VALUES (<Country1>,< Country2>);
INSERT INTO borders VALUES ('B','F');
INSERT INTO borders VALUES ('D','B');
INSERT INTO borders VALUES ('B','NL');
INSERT INTO borders VALUES ('F','D');
I write this code:
Code:
SELECT DISTINCT Country.Name, borders.Country1, borders.Country2 FROM Country
INNER JOIN borders
ON Country.Code = borders.Country1 OR Country.Code = borders.Country2
WHERE borders.Country1 IN ('F','D') AND borders.Country2 IN('D', 'F')
ORDER BY Country.Name;
I expect to see also ‘B’ in result but I just see ‘F’ and ‘D’