mdnfiras
mdnfiras

Reputation: 959

unique combination of 2 columns in phpmyadmin database

I have a table with 3 columns : id, person and code.

I want that the combination of person and code to be unique in the table, wich means that the same person with the same code is not allowed more than one time in the table.

How can I set such thing in phpmyadmin?

Thanks for help and excuse my english.

EDIT

I have the 2 columns selected in my screen :

enter image description here

How do i proceed?

Upvotes: 11

Views: 6113

Answers (3)

Virendra Nagda
Virendra Nagda

Reputation: 658

You should select both fields and choose unique key.you can find this key at bottom field near primary key.

Upvotes: 1

po_taka
po_taka

Reputation: 1856

Since id is already primary key, you should choose "unique" Shown on screenshot below

enter image description here

Upvotes: 16

genespos
genespos

Reputation: 3311

Click in table name so to have the fields view.

Select the two fields you need.

Click on key at the bottom of fields.

Upvotes: 1

Related Questions