Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 421
Firas Medini Avatar asked Nov 18 '15 05:11

Firas Medini


3 Answers

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

enter image description here

like image 115
po_taka Avatar answered Sep 18 '22 08:09

po_taka


Click in table name so to have the fields view.

Select the two fields you need.

Click on key at the bottom of fields.

like image 43
genespos Avatar answered Sep 18 '22 08:09

genespos


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

like image 37
Virendra Nagda Avatar answered Sep 20 '22 08:09

Virendra Nagda