Lets assume this is your db data:
column1 | column2 | column3
1 | 2 | 1
1 | 2 | 2
1 | 2 | 1
3 | 1 | 2
1 | 2 | 2
1 | 2 | 2
1 | 2 | 2
First query
In the first example you will get all column combinations from the db (as GROUP BY 1,2,3
does nothing) including duplicates, so it will return:
1 | 2 | 1
1 | 2 | 2
1 | 2 | 1
3 | 1 | 2
1 | 2 | 2
1 | 2 | 2
1 | 2 | 2
2nd query
Second example takes unique values for column tuples so you will end with
1 | 2 | 1
1 | 2 | 2
3 | 1 | 2
3rd query
Last query takes all values from three columns and then it removes duplicates from that set. So you will get all values from any of the tables. In the end this will return
1
2
3
Does this makes it clear?