tags:

views:

26

answers:

1

I'm having a hard time finding the documentation for creating a unique dependency in a table where, for example, there are 2 columns and each one can have multiple similar values, but there must never be 2 rows where both columns have the same value (as in another row)...

in other words...

    colA       colB
row1  1          2  //this is ok
row2  1          3  //this is ok
row3  2          2  //this is ok
row4  2          2  //this would NOT be ok, because this is just like row 3, and that combination should be unique.
+3  A: 

Sounds like you just want a UNIQUE constraint on the columns in question. In MySQL something like:

ALTER TABLE MyTable ADD UNIQUE (colA, colB);
blahspam
thanks... I misunderstood UNIQUE to restricting uniqueness for one column, rather than combinations.
Dr.Dredel