Hi,

I want to join a table with itself to get all possible combinations of the variable Name in two columns. My first attempt was this:

SELECT P1.Name, P2.Name

FROM Pairs AS P1

INNER  JOIN  Pairs AS P2

ON P1.Group = P2.Group

WHERE P1.Name <> P2.Name

The thing is that I would also like to eliminate duplicates, i.e. I do not want both the combinations Name1 (in column 1) Name2 in (column 2) and Name2 (in column 1) Name1 (in column 2). One of these rows needs to be eliminated. How do I do this?

i can't tell completely what you are meaning, but looks like a group by should take care of it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.