I am developing an application that should bring people together. Each person can correspond only to one other person. So, in the table below, I'm trying to make the values ββfrom user1 and user2 unique in both fields:
CREATE TABLE `match_table` (
`user1` int(11) NOT NULL,
`user2` int(11) NOT NULL,
UNIQUE KEY `user2` (`user2`),
UNIQUE KEY `user1` (`user1`))
So, for example, the following INSERT statement should ignore lines 2 and 4. Or, at a minimum, I need to be able to mark those lines that need to be ignored. Note that line 5 is ok because lines 2 and 4 were ignored.
INSERT IGNORE INTO match_table (user1, user2)
VALUES
(1,2),
(2,3),
(4,5),
(6,4),
(3,6)
Is there any index that can do this? .. Otherwise, there are some UPDATES that I could do after insertion that could mark those that I want to ignore?
Jesse