MySQL: TRIGGERS

  Рет қаралды 139,898

Bro Code

Bro Code

Күн бұрын

Пікірлер
@BroCodez
@BroCodez 2 жыл бұрын
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";
@AMANMUJAWAR-sq6qv
@AMANMUJAWAR-sq6qv Жыл бұрын
Bro Code Sir, I have dought at 1:51 I am getting the error for not using the where clause after set command Can you please let me know😢
@oghaliss
@oghaliss Жыл бұрын
@@AMANMUJAWAR-sq6qv Hi, the error is due the Safe Update Mode in MySql, in order to disable it you have to execute the following SET SQL_SAFE_UPDATES = 0; then you can make the updates, and after that, re-enable it in order to avoid any unwanted changes with the following command SET SQL_SAFE_UPDATES = 1;
@Nxtfbrdf
@Nxtfbrdf Жыл бұрын
justice for Plankton ,he did nothing wrong
@ahndeux
@ahndeux 10 ай бұрын
Maybe just consider he had the wrong skin color and DEI require certain "adjustments" to the employee tables.
@Music_H3b
@Music_H3b 5 ай бұрын
😂😂 elon musk's mindset
@gamingweb1090
@gamingweb1090 2 жыл бұрын
Such underated channel
@VisceralBoredom
@VisceralBoredom Жыл бұрын
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.
@kunalsoni7681
@kunalsoni7681 Жыл бұрын
Now I have accomplished the whole playlist of MYSQL very happy and learned so much from the playlist
@Klavkalashhh
@Klavkalashhh 8 ай бұрын
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.
@googlegoogle1610
@googlegoogle1610 2 жыл бұрын
best video explains the concept of trigger
@Monsta1291
@Monsta1291 2 жыл бұрын
do stored procedures next please. Love the videos, keep up the good work!!!
@hoangvietng7100
@hoangvietng7100 Жыл бұрын
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.
@hoanginh1437
@hoanginh1437 5 ай бұрын
so hard to learn, but your video take less time to know, thank you for this pure video, may god bless you bro
@SardorSaydazimov-b6h
@SardorSaydazimov-b6h 7 ай бұрын
amazing tutorial
@panos21sonic
@panos21sonic 2 жыл бұрын
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
@sumanshah5750
@sumanshah5750 2 жыл бұрын
Thanks you for your informative video with your efforts.
@sinariamith6664
@sinariamith6664 6 ай бұрын
Just finished all the videos. Thank you for the clear explanation sir
@kristijanlazarev
@kristijanlazarev Жыл бұрын
godlike study material
@marekbartczak4363
@marekbartczak4363 2 жыл бұрын
Good job! Please keep quality of your videos.
@Coco-iy4lx
@Coco-iy4lx 6 ай бұрын
You were God sent man. This tutorial really helped me out A LOT! Thanks so much!
@Kodithuwakku123
@Kodithuwakku123 22 күн бұрын
Thank you very much for this 5 Star course!!! Learned a lot ❤
@FahimMahmud-m3b
@FahimMahmud-m3b 4 ай бұрын
The many examples were definitely helpful.
@RickyCalamba
@RickyCalamba 7 ай бұрын
nice video bro....
@chef_david1
@chef_david1 Жыл бұрын
Very well explained, Thanks
@artianrika8329
@artianrika8329 11 ай бұрын
Thank you very much for this 5 Star course!!! Learned a lot
@GG-tr7qn
@GG-tr7qn 2 жыл бұрын
Make a tutorial for PostgreSQL too. That would be extremely helpful.
@shawnieceadams1040
@shawnieceadams1040 11 ай бұрын
Currently in a database class. I hated Java but it’s so much easier doing SQL your examples and explanations are great
@al-cadaalachannel3194
@al-cadaalachannel3194 7 ай бұрын
Wow! Thanks a lot ❤you have explained it in its best way which I have never seen before.
@randalsullivan4453
@randalsullivan4453 Жыл бұрын
Great video series! Your presentation was easily understood and easy to follow Thank you!
@erikg321
@erikg321 7 ай бұрын
Amazing video. Great explanation!
@coomlord5360
@coomlord5360 19 күн бұрын
And that marks the end, hell yea. Honestly just wish functions were touched on like triggers and stored procedures. We got to see some of the built in functions, but never got to go over a user defined function. Nonetheless a really nice playlist for getting down the basics and syntax of mysql and sql respectively. Thank you bro
@Lilyofc
@Lilyofc Ай бұрын
goated youtuber🍺
@hadibq
@hadibq 6 ай бұрын
Thanks of the great tutorials 👍👍
@akshaypatil8155
@akshaypatil8155 Жыл бұрын
4:51 why their are keywords like before and after.....so when we are dealing with another table that is when we use AFTER keyword ????simply if we are changing hourly_pay, it should immediately reflect into annual_salary? Plz reply with the reasons for Before and After....
@TheAnimeSounds
@TheAnimeSounds Жыл бұрын
It is really self explanatory, you asking yourself WHEN trigger has to activate. Thats it. In calculating salary case he chose to activate this trigger BEFORE UPDATING anything on table of employess. This can make you question why, so lets put easier example. Lets say, that column salaries has to be NOT NULL, therefore whenever you would INSERT new records, you coulnt put NULL values in sql statements, but if you create a trigger that will activate BEFORE INSERT / UPDATE on that table, salary value will be calculated with a proper NOT NULL value, so you wont have any errors even if you want to put null value in salary column (ofcourse assuming that hourly_pay column is a proper number) In case of calculating expenses, he wanted to calculate expenses anytime data was added or changed in employe table ( so AFTER a data was changed to use that new data to calculate new value), so he created a trigger for expenses table that will activate AFTER INSERT / UPDATE ON employee table. There's no point in calculating expenses before since data are different after you changed them.
@akshaypatil8155
@akshaypatil8155 Жыл бұрын
@@TheAnimeSounds Thanks mate....I live in India. I am looking for a remote job, I am applying via linkedin to the US companies.....any suggestions for me???? I know SQL, Power BI and Python(Numpy, Pandas, Seaborn, Scikit)
@TheAnimeSounds
@TheAnimeSounds Жыл бұрын
@@akshaypatil8155 Im just starting to learn myself soooo :) unfortunetly no :P
@salmahazem1616
@salmahazem1616 3 ай бұрын
bro thanks for this series it's really useful
@astrk11
@astrk11 13 күн бұрын
Thanks a lot bro, you are doing God's works right here lol
@miqeladzemevele
@miqeladzemevele Жыл бұрын
great job bro, you are sharp as blade
@hometheatre9978
@hometheatre9978 5 ай бұрын
My opinion is to let a database just be a data store and program all these functions in your chosen programming language. Trying to debug and maintain these SQL functions would be a nightmare if you start creating lots of them!
@angryman9333
@angryman9333 2 жыл бұрын
Please upload nodejs your content is priceless
@turrnut
@turrnut Жыл бұрын
9:48 Turbotax: Don't do your taxes.(not sponsored) 12:12 Poor Plankton got fired and reemployed twice
@peharda
@peharda Жыл бұрын
One last example then I promise we are done. I mean ... it's not like you are holding me against my will bro. I kinda wanna learn this :D
@nahidhasan5732
@nahidhasan5732 7 ай бұрын
Great Job Bro 🖤
@TimmyTurds
@TimmyTurds 7 ай бұрын
nice
@RickyCalamba
@RickyCalamba 7 ай бұрын
really?
@TimmyTurds
@TimmyTurds 7 ай бұрын
yeah
@jritzeku
@jritzeku Жыл бұрын
How would you decide between applying triggers in these scenarios vs doing so programmatically in backend code as a software engineer?
@JohnDoe-oh7gf
@JohnDoe-oh7gf Жыл бұрын
Cool vids dude.
@attacker21
@attacker21 11 ай бұрын
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 😅
@bekturasanbekov1979
@bekturasanbekov1979 7 ай бұрын
thx for lesson bro, as always !
@ERRORETJGaming
@ERRORETJGaming Жыл бұрын
Hey. Nice
@MKSVL
@MKSVL Жыл бұрын
hi man thank you for this job i just wondering in the last example if the user enter less hourly_pay it couldnt work because the new salary is less than the old salary however thank you man
@Osamah001
@Osamah001 8 ай бұрын
can you do a video for random numbers in columns please.
@guilhermedovale7943
@guilhermedovale7943 10 ай бұрын
The most surprising thing to learn on this video is that plankton is fr named sheldon kkkjkjk
@mikefantos2878
@mikefantos2878 2 ай бұрын
Not working with Popsql and the reason was because you need to use BEGIN and END when you write a trigger.
@mohitdhiman5604
@mohitdhiman5604 Жыл бұрын
Hey man could you please tell me how did you managed to make your scripting background black?
@stickercode
@stickercode Жыл бұрын
I got a general knowledge on triggers but could not quite follow what's the difference between after and before thing. Like after insert and before insert. I did not comprehend the logic lies behind it. Can you explain like telling it to a layman.
@walk4754
@walk4754 Жыл бұрын
I got confused by that too. I did a bit of googling and I think I get the gist of it. When it's in the same table, we use "before". If it involves data from another table, it's "after". But I may be wrong and this could just be the blind leading the blind lol.
@stickercode
@stickercode Жыл бұрын
@@walk4754 :) thanks anyway
@iamsherk2605
@iamsherk2605 8 ай бұрын
Please do functions
@MKSVL
@MKSVL Жыл бұрын
Thanks
@FloresMarkDeaniel
@FloresMarkDeaniel Жыл бұрын
please do a springboot tutorial
@quangphanminh1084
@quangphanminh1084 5 ай бұрын
what is the difference between before insert and after insert?
@josephdaquila2479
@josephdaquila2479 4 ай бұрын
So this will work in the background? Even if a user doesn't have the database open?
@lazarus6745
@lazarus6745 2 жыл бұрын
Is this the last video of this series ?
@zorrofit5880
@zorrofit5880 2 жыл бұрын
I also would like to know that.
@enriquepasa
@enriquepasa 2 жыл бұрын
@@zorrofit5880Me too. But he wrote he's not sure himself for how long series will go
@Shohjahon149
@Shohjahon149 2 жыл бұрын
Hi bro, are you going to make node js videos?
@_indrid_cold_
@_indrid_cold_ 7 ай бұрын
I don’t get it. How can the salary column recalculate based on the hourly pay BEFORE the hourly pay has been updated? Surely the hourly pay update needs to happen prior to the salary being recalculated? Can anyone help me to wrap my head around that?
@pramodkorgaonkar5629
@pramodkorgaonkar5629 7 ай бұрын
Here is my understanding Whenever you update hourly pay, before the update happens the trigger will have both old and the new values for all the columns in your table. So using the 'NEW' keyword for the salary you will get the new salary that is going to be updated, using that you are calculating the hourly pay and updating them simultaneously. Hope this helps 😀🙌🏼
@nihongo_
@nihongo_ 9 ай бұрын
W course
@aragogpotter919
@aragogpotter919 Жыл бұрын
What is difference between before and after
@pranitrai9255
@pranitrai9255 Жыл бұрын
12:13 Poor Plankton xD
@mansifurrahmanrafsan2777
@mansifurrahmanrafsan2777 2 жыл бұрын
Is this sql series completed?
@genshinsbizzareadventures
@genshinsbizzareadventures 5 ай бұрын
Bullying plankton😂😂😂
@fayrusrabiya2213
@fayrusrabiya2213 2 жыл бұрын
Can you please show how to create trigger for username by taking first 4 char from first name and last name please
@TheAnimeSounds
@TheAnimeSounds Жыл бұрын
with this video, you know already how to create triggers, what you dont know i assume is how to take first 4 chars from a text , just check build in methods, for example left() or right() and create your trigger accordingly to your needs by following this video.
@sunkojusurya2864
@sunkojusurya2864 5 ай бұрын
Love❤ed this channel. Thanks for the videos bro. Can u also upload for Post GRE SQL. Subscribed channel
@riperboyxl3216
@riperboyxl3216 2 жыл бұрын
Hi bro, will you make a single video of all the SQL videos?
@BroCodez
@BroCodez 2 жыл бұрын
Most likely. I'm not sure how long I'm going to continue this series tho.
@lazarus6745
@lazarus6745 2 жыл бұрын
@@BroCodez Why Bro?
@Reham.gad3
@Reham.gad3 3 ай бұрын
that's so hardddddddd
@nick.h7566
@nick.h7566 8 ай бұрын
Most of my issues come from triggers...
@ardcodelover
@ardcodelover 2 жыл бұрын
wow
@eagle960
@eagle960 Жыл бұрын
poor Plankton 🤣
@brylejanm.nacalaban9506
@brylejanm.nacalaban9506 9 ай бұрын
i feel sorry for plankton
@rust_y
@rust_y Жыл бұрын
PLANKTON NOOOOOOOOOO
@trubnikov
@trubnikov Жыл бұрын
Absolutely Brilliant Fucking Video! Thanks Bro!!! ❤
@nasarhusain9453
@nasarhusain9453 6 ай бұрын
I am facing unknown column hourly-pay in field list error after create update trigger. Please tell me solution
Triggers and Events in MySQL | Advanced MySQL Series
14:42
Alex The Analyst
Рет қаралды 68 М.
MySQL VIEWS are awesome
6:03
Bro Code
Рет қаралды 71 М.
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41
MySQL Full Course for free 🐬
3:00:00
Bro Code
Рет қаралды 2,1 МЛН
MySQL: STORED PROCEDURES
8:02
Bro Code
Рет қаралды 103 М.
MySQL: ON DELETE
7:31
Bro Code
Рет қаралды 26 М.
Zenless Zone Zero Is Making DRASTIC Changes...
7:04
Gacha Gamer
Рет қаралды 114 М.
MySQL: SUBQUERIES
6:46
Bro Code
Рет қаралды 114 М.
SQL Course for Beginners [Full Course]
3:10:19
Programming with Mosh
Рет қаралды 12 МЛН
Learn Database Normalization - 1NF, 2NF, 3NF, 4NF, 5NF
28:34
Decomplexify
Рет қаралды 2,1 МЛН
MySQL: INDEXES are awesome
6:26
Bro Code
Рет қаралды 61 М.
MySQL SELF JOINS are ... ughhh
10:03
Bro Code
Рет қаралды 75 М.
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН