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