I have MySQL MyISAM table:
Table friends(id, friend_id):
1, 5
5, 1
2, 6
6, 2
3, 7
How to delete reverse records? If for record values «1, 5» exist record with values «5, 1» i need to delete «5, 1».
Thanx for help!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
EDIT
A bit nicer syntax would be:
But execution time is the same.
As well, I’ve created this small script for a quick & dirty benchmark.
Results:
No index:
Separate index on columns
idandfriend_id:Unique index on
(id, friend_id):Conclusions: