All right.
So let's go ahead and look at uh what conflicts do.
Update.
So in the previous lecture we are going to work with uh conflicts do nothing.
And we use the email and the primary key.
So if we go ahead and uh, say check the email and go ahead and execute this, we have this workout
file.
But now we actually want to do something important.
Imagine you have this, uh, database and someone has entered their details into your server, and now
they want to update that.
I'm sure you might have learned about the update, but are not doing that with a real time.
So how can you be able to do this?
In order to do this, using the old conflict due update, we're going to remove the do nothing, and
now we're going to replace that with a do update.
Now if I go ahead and, uh, this time around or I need to do is let me say this person enters first
name, last name, age, gender, uh, email a latent cool.
And the person comes back and say, right now my email has changed from Steve.
And it is now, uh, just, uh uh.
Memoir that's calm.
And, uh, let's go ahead and, uh, see what actually happens.
And, uh, if you go ahead and run this, you might get into problem.
Let's check it out.
Now there is a problem.
What happens is that when you insert this, you go ahead and, uh, say, what I need to do here is
to set the email to the new email address that the person wants to insert.
And, uh, what are you going to do is you go ahead and uh, say update set and then email a code to
the excluded.
Dot.
So this is email equal event equal sign here.
And the the discredit dot.
Email or I know we have a excluded dot email.
And we're going to set this to the new email that is right in here.
And let's go ahead and run this and check it out.
Now we can drag this and move down.
And now you can see that we have this right in here.
And uh, it is a new one.
And that is just at uh manoa.com.
But what happens is that this actually created a new person.
And what if I want this exact person that is the ID 1104 or 1001 for that is the last portion right
in here to be the extra person without creating a new one.
What am I going to do?
What I need to do is I'll go right in here and I'm going to say students underscore ID and now I'm going
to work on this sent ID and I'm going to choose that ID colon 1014.
And remember this ID has existed.
And now I'll go right in here.
And I'm going to change this to students underscore ID.
And if I do that I'm now going to create a new or a set in new rule.
But I'm going to affect this.
So go right in here and say that this is going to be Steve at gmail.
And now let's go ahead and execute this query and check it out.
Drag this down.
Now you can see that ID 1014.
Judge Steve has entirely changed from justice at Macomb to justice at gmail.com, and that is applicable
to every other one right here.
So let me go ahead and say I have this ID too.
And I'm going to change this from to ID two.
And let me say the processing, which is a ruse and that is a very fast name.
I'm going to put that here.
And the name is, uh, Mayweather.
That is the last name and went to the place that and the.
Now the email is no and no.
It also updated the email.
Okay.
Now let's go ahead and say the email because it doesn't have an email but it has come back to an email.
But I'm going to say the email address is going to be, uh, Rose Rose Mayer at gmail.
And let me say it's going to be female and everything remains just the same.
And now I'm changing both the email and I'm changing the gender as well.
So if I want to affect this gender or the gender is already female, I can change the gender to know
what.
Let's take that one step at a time.
Now, what I need to do is to go ahead and set the set the email and exclude that.
And then this is going to be updated.
This email is the no.
Which is a 16 year.
What excluded email is the new email we added and if required is the query.
Check it out.
Now we have this and it moved down at the last one.
Check it out.
And uh.
Let's go over here.
And check it out.
So we can also use this to check out the students.
Select all from students.
Where Students underscore id is equal to two and put a semicolon at the end.
And let's go ahead and check it out.
Now you can see that we have a Rosie.
And the new email address is a rosemary.
And it is female.
So because I have large data is sometimes you can be able to see where this actually entered.
And that is why I have to select that and identify this.
So you can see that you can actually update and using what we call the score and check it out again
using what we call a no conflicts do updates.
So we now set this and you can also set multiple.
Let me want to say I want to set what the gender let's say gender.
Or I need to just put a comma.
And I'm going to say gender is equal to.
Escalate that escalated to gender.
So you can add onboard a first name.
You can upload the last name and let me go ahead and also add maybe the first name first.
I can just go over to the next line with a comma, and let's move on to the next line.
First underscore name is equal to.
Excluded dot first underscore name.
First underscore name.
And now we're going to change the first name.
And the first name is Rosalyn I'm going to change this to.
Let me change this.
And I want to put the Rosa at the end.
So can we want to see it.
And this is a waiter.
And I'm going to add okay.
We didn't actually specify the last this uh last name.
And the next one we changed is the gender.
So I'm going to change this gender to male.
All right.
Now we can go ahead Whitehead and R is the cutest query.
And now we see that the first name has changed to Lind Rosa and the gender has changed from female to
male.
So that is what the Akaflieg to do update does for you.
I hope that is cool.
So you can also use a conflict, do nothing and you can also use on conflict.
Do update to do nothing actually doesn't do anything.
What to do update actually updates the table without having an error, because someone can actually
come back to your table and say, I want to update this table having the same ID without having any
problem.
Whenever you use no on conflict, do update.
Hope that is cool.
Go ahead and check it out and practice with it.
If you have any question.
Go ahead and use the question and answer section, and I'm going to get back to you as soon as possible.
Thank you so much.
And I'm going to see you in the next video lecture.