Hi to all im trying to create a trigger for this table:
create table Episode(
  title varchar(25) not null,
number int not null,
  length time not null,
  aired date not null,
  serie_name varchar(25),
PRIMARY KEY(title,number),
  FOREIGN KEY (serie_name)REFERENCES Serie(name)
  ) ENGINE=InnoDB;
this is a table of a db that saves some tv series...so the trigger have to check if i m trying to insert a new episode that had benn aired before the precedent one....But i have some problem any solutions? i tried this:
create trigger ControlDataEp
 before insert on Episode
 for each row
begin
if new.aired<(select aired from Episode where title=new.title and number=new.number-1)
    then raise.application_error(-21,'error');
end if;
end;
 
     
     
    