mysql - How to remove duplicate records from the table -


i have table following columns

name      friend ---------------------- apple     flavour flavour   apple new       banana banana    flavour 

i want remove columns having records same combination example apple, flavour , flavour, apple same. want 1 record among 2 records when have such combinations repeated.

you use least , greatest functions fetch unique combination.

for example,

sql> data as(   2  select 'apple' a,   'flavour' b dual union   3  select 'flavour',   'apple' dual union   4  select 'new',   'flavour' dual union   5  select 'banana',   'fruit' dual   6  )   7  select least(a,b) a,   8    greatest(a,b) b   9  data  10  group least(a,b),  11    greatest(a,b)  12  /        b ------- ------- banana  fruit apple   flavour flavour new  sql> 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -