我有一些像Sql Fiddle这样的表。
我希望此表仅选择以下值(删除重复项):
from | to 46 0 46 18 46 50 46 39 46 11 46 12 46 56
我使用DISTINCT
关键字,但这会返回以下值:
46 0 46 18 46 50 46 39 46 11 11 46 46 12 46 56
答案 0 :(得分:3)
<强> Greatest and Least 强>
SELECT distinct greatest(`from`,`to`),least(`from`,`to`)
from `tsk_private_message`
<强> SQL FIDDLE 强>