MySQL: TRIGGERS

preview_player
Показать описание
#MySQL #tutorial #course

00:00:00 intro
00:00:33 setup part 1
00:02:01 BEFORE UPDATE
00:05:45 BEFORE INSERT
00:08:14 setup part 2
00:10:45 AFTER DELETE
00:12:37 AFTER INSERT
00:14:34 AFTER UPDATE
00:16:25 conclusion

CREATE TRIGGER before_hourly_pay_update
BEFORE UPDATE ON employees
FOR EACH ROW
SET NEW.salary = (NEW.hourly_pay * 2080);

CREATE TRIGGER before_hourly_pay_insert
BEFORE INSERT ON employees
FOR EACH ROW
SET NEW.salary = (NEW.hourly_pay * 2080);

CREATE TRIGGER after_salary_delete
AFTER DELETE ON employees
FOR EACH ROW
UPDATE expenses
SET expense_total = expense_total - OLD.salary
WHERE expense_name = "salaries";

CREATE TRIGGER after_salary_insert
AFTER INSERT ON employees
FOR EACH ROW
UPDATE expenses
SET expense_total = expense_total + NEW.salary
WHERE expense_name = "salaries";

CREATE TRIGGER after_salary_update
AFTER UPDATE ON employees
FOR EACH ROW
UPDATE expenses
SET expense_total = expense_total + (NEW.salary - OLD.salary)
WHERE expense_name = "salaries";
Рекомендации по теме
Комментарии
Автор

CREATE TRIGGER before_hourly_pay_update
BEFORE UPDATE ON employees
FOR EACH ROW
SET NEW.salary = (NEW.hourly_pay * 2080);

CREATE TRIGGER before_hourly_pay_insert
BEFORE INSERT ON employees
FOR EACH ROW
SET NEW.salary = (NEW.hourly_pay * 2080);

CREATE TRIGGER after_salary_delete
AFTER DELETE ON employees
FOR EACH ROW
UPDATE expenses
SET expense_total = expense_total - OLD.salary
WHERE expense_name = "salaries";

CREATE TRIGGER after_salary_insert
AFTER INSERT ON employees
FOR EACH ROW
UPDATE expenses
SET expense_total = expense_total + NEW.salary
WHERE expense_name = "salaries";

CREATE TRIGGER after_salary_update
AFTER UPDATE ON employees
FOR EACH ROW
UPDATE expenses
SET expense_total = expense_total + (NEW.salary - OLD.salary)
WHERE expense_name = "salaries";

BroCodez
Автор

justice for Plankton, he did nothing wrong

Nxtfbrdf
Автор

words cannot describe how grateful i am for discovering your channel a while ago.
I first found out the java course, then went to python and then on my database subject in university. ALL of your videos found it useful and simple as hell.
Learned a lot of stuff and you make it look easier man, i appreciate you :>

thank you. Really... thank you.

VisceralBoredom
Автор

Now I have accomplished the whole playlist of MYSQL very happy and learned so much from the playlist

kunalsoni
Автор

I very rarely comment, but man, what a great video. Not unnecessarily long, but still with plenty of content to thoroughly understand the concept. Liked and subscribed, and I'm looking forward to exploring more of this channel. Thank you.

Klavkalashhh
Автор

You were God sent man. This tutorial really helped me out A LOT! Thanks so much!

Coco-iylx
Автор

so hard to learn, but your video take less time to know, thank you for this pure video, may god bless you bro

hoanginh
Автор

do stored procedures next please. Love the videos, keep up the good work!!!

Monsta
Автор

Hey brocode, ive recently finished all non gui vids of your in java, and taking a break before hopping in your introduction to swing. Your C# also made me fall in love with c#, and making it the first language im comfortable using. That being said, would you ever make a ruby series? I had learnt ruby back in 8th grade, and now im the 11th grade, having forgotten mostly everything about it, and i would really like an oppurtunity to brush up on my ruby knowledge, especially since nobody teaches like you do. Have a great day man

panossonic
Автор

I watched all the videos on this list and learned a lot. I like the way you give examples. Your content is excellent. Please continue, thank you very much Bro Code.

hoangvietng
Автор

bro thanks for this series it's really useful

salmahazem
Автор

Make a tutorial for PostgreSQL too. That would be extremely helpful.

GG-trqn
Автор

The many examples were definitely helpful.

FahimMahmud-mb
Автор

Wow! Thanks a lot ❤you have explained it in its best way which I have never seen before.

al-cadaalachannel
Автор

Thanks you for your informative video with your efforts.

sumanshah
Автор

For those who confuse about the last one why the expense total is 356200 is because expanse total=current expanse total which is 254280 +((new salary for plankton which is 208000 or 100*2080 )-(old salary for plankton which is 106.080)) so the result is 356200. How do i know the 100*2800? Okay the answer is he already make before update trigger so it means that when he run the update trigger at the end the of the video he run two trigger which is before update trigger and after update trigger. 100 is the number he set when he run the update query. I hope you guys understand what i mean 😅

attacker
Автор

best video explains the concept of trigger

googlegoogle
Автор

Thank you very much for this 5 Star course!!! Learned a lot

artianrika
Автор

Good job! Please keep quality of your videos.

marekbartczak
Автор

Currently in a database class. I hated Java but it’s so much easier doing SQL your examples and explanations are great

shawnieceadams