you have to check via programming first.
a good way to avoid "checking" is sort the friends so that the lowest ID is always first.
you will need to clean up your current table to make this work.
first, delete the duplicates:
Code:
delete f1
from friends f1
join friends f2
on (f1.friend_a_id, f1.friend_b_id) = (f2.friend_b_id, f2.friend_a_id)
where f1.friend_b_id < f1.friend_a_id
then update the remaining rows where the friends are not sorted properly:
Code:
update friends
set friend_a_id=(@temp:=friend_a_id)
, friend_a_id = friend_b_id
, friend_b_id = @temp
where friend_a_id > friend_b_id
Bookmarks