• support@answerspoint.com

How do I specify unique constraint for multiple columns in MySQL?

1612

I have a table:

table votes (
    id,
    user,
    email,
    address,
    primary key(id),
);

Now I want to make the columns user, email, address unique (together).

How do I do this in MySql?

  • Of course the example is just... an example. So please don't worry about the semantics.

1Answer


0
ALTER TABLE `votes` ADD UNIQUE `unique_index`(`user`, `email`, `address`);
  • answered 8 years ago
  • G John

Your Answer

    Facebook Share        
       
  • asked 9 years ago
  • viewed 1612 times
  • active 9 years ago

Best Rated Questions