 What is going on everybody, my name is Alex Friedberg and today we're going to be looking at updating and deleting data in a table. Now what's the difference between inserting data into a table and updating data? Insert into is going to create a new row in your table while updating is going to alter a pre-existing row. While deleting is going to specify what rows you want to remove from your table. So let's get going with the updating. So down here Holly Flax does not have an employee ID, age or gender. Now we want to update this table to give her that information. So let's do update. Now we need to specify what table we're going to be hitting off of so let's do SQLTutorial.dbo.employedemographics. So now we're going to use something called set and set is going to specify what column and what value you actually want to insert into that cell. So let's set her employee ID equal to and it's going to be 1,012 and we have to specify which one to do this to because if we ran just this is going to set every single employee ID to 1,012 because we haven't specified that we only want Holly Flax's row to be updated. So now we have to specify where first name is equal to Holly and last name is equal to Flax. So now let's run this and see what we get. So one row has been affected. Let's see what we got and there we go. As you can see the employee ID was updated exactly how we specified it right here. So we also want to update age and gender and let's do that in the same query. So let's set the age equal to 31 and instead of using and we actually need to use a comma. So let's say age equal to 31 comma gender is going to be equal to female and let's run this and see what we get. There you go. Now let's look at our table and as you can see it was updated to 31 and female. So very easy, very easy to specify what you want. Oftentimes tables like this will have a unique key like employee ID is our unique key in this table. So I could easily just say where the employee ID is equal to and then you know 1,012. So it's an easy way to specify what employee you're trying to update. So now let's look at the delete statement. The delete statement is going to remove an entire row from our table. So let's do delete and we actually need to say from and we have to specify what table we want to be removing this information from. So let's do SQLTutorial.dbo.employeeDemographics and now we need to specify what row we want to remove. So let's do where employee ID is equal to and let's choose a completely random employee ID 1,005. So let's run this and see what happens. So one row is affected, let's look at our table and as you can see 1,005 is now gone. Now you have to be very careful when you use the delete statement because once you run it you cannot get that data back there's no way to reverse a delete statement. So if I had gotten rid of this where statement and I ran this it would delete everything from the entire table and you could not get that data back. So a little trick that I use before I actually run a delete statement is I make it a select statement because you're going to select everything where the employee ID is equal to let's just do 1,004 and now when you run this you are going to see exactly what you will be deleting and now we know that Angela Martin that entire row is going to be gone. If I hadn't done that and I just went like this and I wrote delete and I only had this running I would not know that this information is going to be the only one that's gone. Maybe I made a mistake down here, maybe I accidentally put something in there that wasn't supposed to be in there and now I'm deleting much more than I thought I was actually going to delete. So using the select statement can be a very good safeguard against accidentally deleting data that you do not want to delete. So that is update and delete thank you guys so much for watching I really appreciate it if you like this video be sure to subscribe below and I'll see you in the next video.