Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

mysql bidirectional composite primary key

create trigger bi_foo before insert on foo
for each row
begin
  if exists(select 1 from foo where bar1 = NEW.bar2 and bar2 = NEW.bar1)
  then
    signal sqlstate '50000' set message_text="Oops";
  end if;
end
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #mysql #bidirectional #composite #primary #key
ADD COMMENT
Topic
Name
7+3 =