i m trying to execute trigger on before insert of table.
Table structure :-
service :- id, name.
clinic :- id, company_id, name, service_id.
user :- id, clinic_id, company_id, service_id.
CREATE TRIGGER user_before_insert_trigger BEFORE INSERT ON `user` FOR EACH ROW
BEGIN
SET NEW.service_id= (select CL.service_id from clinic as CL where CL.id=NEW.clinic_id LIMIT 1);
SET NEW.company_id= (select CL.company_id from clinic as CL where CL.id=NEW.clinic_id LIMIT 1);
END
i need to set service_id
and company_id
on insert using trigger.
i had execute separate queries to get service_id
and company_id
from clinic
table. that need to convert in a single query.
Please have some suggestion to improve query.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2tyVpgv
via IFTTT
Aucun commentaire:
Enregistrer un commentaire