deib97 Posted January 24, 2014 Share Posted January 24, 2014 Hi, i have 2 table, a table alat and a table mutasi_alat. Every I do action insert to the table mutasi_alat, with a relation alat.id_alat and insert date newer then the value that is in the table mutasi_alat.id_cabang. The table will trigger an update to the table alat.cabang_terakhir. Table 1 : alat Table 2 : mutasi_alat I want to be trigger update into table alat after any action insert in table mutasi_alat. Do I have to make a single trigger or storeprocedure with this conditions? thanks Link to comment https://forums.phpfreaks.com/topic/285636-something-trigger-for-update-other-table-with-some-condition/ Share on other sites More sharing options...
deib97 Posted January 25, 2014 Author Share Posted January 25, 2014 DROP TRIGGER IF EXISTS `auto_update_tabel_alat`; DELIMITER // CREATE TRIGGER `auto_update_tabel_alat` AFTER INSERT ON `mutasi_alat` FOR EACH ROW update alat set cabang_terakhir=NEW.id_cabang where id=NEW.id_alat // DELIMITER ; Still not complete.. Link to comment https://forums.phpfreaks.com/topic/285636-something-trigger-for-update-other-table-with-some-condition/#findComment-1466487 Share on other sites More sharing options...
deib97 Posted January 28, 2014 Author Share Posted January 28, 2014 DROP TRIGGER IF EXISTS `auto_update_tabel_alat`; DELIMITER // CREATE TRIGGER `auto_update_tabel_alat` AFTER INSERT ON `mutasi_alat` FOR EACH ROW update alat set cabang_terakhir=(SELECT mutasi_alat.id_cabang FROM mutasi_alat where mutasi_alat.tgl_berlaku=(select max(mutasi_alat.tgl_berlaku) from mutasi_alat where id_alat=NEW.id_alat)) where id=NEW.id_alat // DELIMITER ; Link to comment https://forums.phpfreaks.com/topic/285636-something-trigger-for-update-other-table-with-some-condition/#findComment-1466826 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.