Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql structure double unique

Tags:

php

mysql

I am trying to make a mysql table and have got stuck with making it.

2 columns required:

aid
bid

The trick is aid is not unique and bid is not unique, but the combination of aid-bid IS unique.

EG:

a b ok?
0 1 y
0 2 y
0 7 y
1 1 y
1 7 y
8 3 y
0 7 N - since 0 7 is already in table...

How can I make this table in sql so it works?

like image 520
David19801 Avatar asked Dec 07 '25 04:12

David19801


1 Answers

create table my_table (
a int,
b int,
unique key (a,b) );
like image 68
Nicola Cossu Avatar answered Dec 08 '25 18:12

Nicola Cossu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!