0

I have some tables like this Sql Fiddle.

I want this table to select only the following values (remove duplicates):

from | to
46  0  
46  18  
46  50  
46  39  
46  11   
46  12  
46  56

I use DISTINCT keyword, but this returns the following values:

46  0  
46  18  
46  50  
46  39  
46  11  
11  46  
46  12  
46  56
halfer
  • 19,824
  • 17
  • 99
  • 186
user3077624
  • 125
  • 1
  • 4
  • Please do not ask your questions more than once, especially on the same day, as it risks causing duplicate effort. – halfer Dec 22 '13 at 17:19

1 Answers1

3

Greatest and Least

SELECT distinct greatest(`from`,`to`),least(`from`,`to`)
from `tsk_private_message`

SQL FIDDLE

Prahalad Gaggar
  • 11,389
  • 16
  • 53
  • 71