0

I have these two table called "cases" and attendance respectively which has four columns:

cases- id empid reaction date_t 1 EMP12654 interested 2017-09-22 attendance- id empid logintime logouttime date_t flag workinghours call_att 1 EMP12654 00:14:49 05:14:49 2017-09-18 set 6 1 

What I want to do is create a trigger on cases table that updates call_att column of attendance table with number of entries in reaction column of cases table, this is what I have tried so far

 CREATE DEFINER=`root`@`localhost` TRIGGER `number_call` AFTER INSERT ON `cases` FOR EACH ROW BEGIN UPDATE attendance set call_att=call_att +1 WHERE empid=new.empid AND date_t=new.date_t; END 

But that doesn't seem to work. I am quite new to triggers.

2
  • Please share the table cases and attendance as text data tables with example data. Commented Sep 18, 2017 at 14:05
  • if possible also add the error message in question , so it is easy to understand Commented Sep 18, 2017 at 14:07

1 Answer 1

1

try this

CREATE TRIGGER number_call AFTER INSERT ON cases FOR EACH ROW BEGIN UPDATE attendance set call_att=(select count(*) from cases where empid=NEW.empid ) date_t=NEW.date_t; END 
Sign up to request clarification or add additional context in comments.

1 Comment

Its not giving me an error but also not updating the call_att column!!