MySQL Trigger

I have created a trigger that is working as expected
 CREATE DEFINER=`root`@`%` TRIGGER trg_DDAI_Service
    AFTER INSERT ON tbl_comments
    FOR EACH ROW BEGIN
 
    INSERT INTO tbl_service_log
    SET 	DDAI_ServicesID = '1',
		DDAI_Services_Date = NOW();

Open in new window


the table tbl_comments also has a column D_ID, How do i include the D_ID value into tbl_service_log
BrogrimInformation Systems Development ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Is there a column in the service_log to receive the D_ID value.

Assuming the service_log has a D_ID field then you could just do this

CREATE DEFINER=`root`@`%` TRIGGER trg_DDAI_Service
    AFTER INSERT ON tbl_comments
    FOR EACH ROW BEGIN
 
    INSERT INTO tbl_service_log
    SET 	DDAI_ServicesID = '1',
		DDAI_Services_Date = NOW(),
                D_ID = NEW.D_ID;
     END;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
No points for this, but you might want to learn about the TIMESTAMP column definition.
0
BrogrimInformation Systems Development ManagerAuthor Commented:
Thanks
0
Julian HansenCommented:
You are welcome - thanks for the points.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.