my table has 2 fields, both are Keys.
I save similar items in that table , like if 2 items are similar but have different Ids (in another table) I use this table to know that they are similar.

so if items 1111, 1112 are the same and 1000,1002,1004 are the same, it'll looks like this-
field1, field2
1111, 1112
1112, 1111
1000, 1002
1000, 1004
1002, 1000
1002, 1004
1004, 1002
1004, 1000

now I want to display the option to delete the connection between 2 items using a form, but I don't want the user to pick 1111,1112 AND 1112,1111 for removal, I want 1 connection to be displayed, and then I'll twist the vars and remove the other connection, but I don't know how to write a query that displays each connection only once!
help please!

One way would be to create a calculated column that concatenates both fields with the smallest first, so you can order and distinct that column.

Although that may work, I guess there has to be a better way.

I'm not sure what u meant but doing a simple DISTINCT on 1 culumn won't work since I'm going to get

and if I wanted to do a second query for each row to find it's conection then I'm going to get
and then for 1112 gonna get 1111, so I have the same connection twice..

Something like:

SELECT field1, field2, IF(field1 < field2, CONCAT(field1, '-', field2), CONCAT(field2, '-', field1)) AS field3
FROM table
GROUP BY field3
ORDER BY field3

This may not work for you in all case, but it will give you the idea.

Be a part of the DaniWeb community

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