help with creating a query that will determine all X1,X2 such that X1 and X2 have different values for D

One table (X) has fields X1 and X2
The next table (Y) has fields X and D

There are foreign Keys for both X1 and X2 that reference field X in table Y

Any help would be appreciated