1

i have created two tables into student database

1) Admission table (rollNO,Name,fname,address,department,addmission_date)

2) Fees Table(rollNO,Name,fname,address,department,Total_fees,Fees_Payment_date)

i want to insert same data of addmission table into fees table which contain same column names like rollNO,Name,fname,address,department using trigger's event "after"

how can i do it? if i insert data into addmission table it will also automatically insert into fees table????

Rooha Ali
  • 129
  • 1
  • 7

1 Answers1

1

Try this code, NEW is ref of admission table insert record contains

DELIMITER //
CREATE TRIGGER `fee_trigg` AFTER INSERT ON `admission`
 FOR EACH ROW BEGIN
 INSERT INTO fee  (rollNO,Name,fname,address,department)
   VALUES( NEW.rollNO, NEW.Name, NEW.fname,NEW.address,NEW.department );
END; //
DELIMITER ;
Girish
  • 11,907
  • 3
  • 34
  • 51