Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

mysql bidirectional composite primary key

CREATE TRIGGER uinsert BEFORE INSERT ON tbl_challenger
 FOR EACH ROW SET NEW.u0 = LEAST(NEW.host,NEW.challenger),
  NEW.u1 = GREATEST(NEW.host,NEW.challenger);
#same for update
CREATE UNIQUE INDEX uniqueness ON tbl_challenger(u0,u1);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #mysql #bidirectional #composite #primary #key
ADD COMMENT
Topic
Name
3+4 =