I have a sql database and i don´t know, how to solve the following problem. For example - the database looks like this
Col A | Col B | Col C
It should be possible that Col A has some dublicate entries / Col B has some duplicate entries - but it should not be possible that the pair of Col A & B can be listed twice. How do i have to prepare the database and insert statement.
Create a unique index on Col A and Col B:
ALTER TABLE `mytable` ADD UNIQUE `unique_index`(`ColA`, `ColB`);
ANSI SQL example:
ALTER TABLE mytable ADD CONSTRAINT unique_index UNIQUE (ColA,ColB);