MySQL UNIQUE Constraint with a condition -


i'm trying create unique index constraint 2 columns (id_1 , id_2) following condition: if 2 different rows have same value in id_2 column, values in id_1 column must same.

is possible?

thanks.

there no declarative constraint support such restriction. scenario describe not satisfy requirements unique constraint. (you can create constraint, won't able add more 1 row identical values id_1 , id_2.

if intent reject insert or update based on restriction, might able accomplish row-level trigger.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -