I have a table called friends with the following structure:
id
user_id
friend_id
and I want the rows to be unique so for example:
1, 6, 12
2, 6, 12
would break! I've achieved this with: ALTER TABLE friends ADD UNIQUE INDEX user_id_friend_id (user_id, friend_id);
BUT I also want the following to not be possible
1, 6, 12
2, 12, 6
How do I do that? I tried doing the same statement but with the fields reversed but it didn't work... Any ideas?