Reputation: 9431
I have the table UserContacts with a column like
and I want to get the following result (which is all the possible pair combinations of the values of that column)... (1,5),(1,6),(5,6)
is it possible?
Upvotes: 0
Views: 3277
Reputation: 1
USE CROSS JOIN
SELECT a.contact_id FROM UserContacts a CROSS JOIN UserContacts b
Upvotes: -2
Reputation: 2238
This should work
SELECT t2.contact_id,t1.contact_id FROM UserContacts t1 JOIN UserContacts t2
WHERE t1.contact_id <> t2.contact_id
Upvotes: 1