Question: create table pairs( number a,number b)

where the data is 

```
1,1
1,2
1,3
2,1
2,2
2,3
3,1
3,2
3,3

```

etc.

what query gives me the unique pairs? 
With this i mean:

```
1,2 or 2,1
1,3    3,1
2,3    3,2

```

Answer: 
I think this is the simplest solution. If it can be guaranteed that there are no duplicated pairs then the `GROUP BY` isn't needed.

```
SELECT a, b 
FROM pairs
WHERE a < b
GROUP BY a, b

```

Output:

```
a   b   
1   2
1   3
2   3

```

You can always change the `<` to `>` if you want the alternate output:

```
a   b   
2   1
3   1
3   2

```

As @TimBiegeleisen pointed out, it could even be further simplified to 

```
SELECT DISTINCT a, b 
FROM pairs
WHERE a < b

```

I'm not sure which of these queries might be the fastest.
```
SELECT sub.output FROM
(
SELECT  CONCAT(a,b, ' or ',
b,a ) output,
ASCII(a)+ASCII(b) asci
FROM tbl_t1 WHERE a!=b
) sub GROUP BY sub.asci;

```