I have this table
id follow_id follower_id
1 | 2 | 3
2 | 2 | 4
3 | 2 | 5
4 | 2 | 6
5 | 3 | 7
6 | 3 | 8
I'd like to skip If i try to insert the "couple" follow_id 2, follower_id 3 without do subquery for the performance
can I do INSERT... ON DUPLICATE KEY UPDATE or something of this?
UPDATE, for symfony user
after answers. i Use Symfony, and for do
UNIQUE INDEX followee_and_follower (follow_id,follower);
http://docs.doctrine-project.org/en/2.0.x/reference/annotations-reference.html#uniqueconstraint