How i can make 2 unique_index validation

How i can make 2 unique_index validation

CdyaCdya Posts: 12Questions: 5Answers: 0

ALTER TABLE yoourtable ADD UNIQUE unique_index(Name, Status);

I need to make 2 unique_index

+-----------------------------------+------------+
|               Name                |    Status  | 
+-----------------------------------+------------+
|               asya                |     1      |    
|               cdya                |     1      |    
|               asya                |     2      |
|               cdya                |     2      |   
+-----------------------------------+------------+

I need to like this table but no duplicate when status same equal.
need to make it validation server-side

Thank you.

Answers

  • CdyaCdya Posts: 12Questions: 5Answers: 0

    ALTER TABLE yoourtable ADD UNIQUE unique_index(Name, Status);

  • allanallan Posts: 63,464Questions: 1Answers: 10,466 Site admin

    If you are using the Editor PHP or .NET libraries for Editor you can also use the unique validator.

    Allan

  • CdyaCdya Posts: 12Questions: 5Answers: 0

    this does not answer I don't know how I can do unique index in 2 column

  • allanallan Posts: 63,464Questions: 1Answers: 10,466 Site admin

    Sorry yes, the built in unique validator will only work with a single column. You'd need to use a custom validator to validate across multiple columns.

    Regards,
    Allan

This discussion has been closed.