UPDATE COMMAND
As we mentioned in our other lessons and explained with examples, select was used to pull data, while the insert allowed us to add new data to our table.
Update, on the other hand, changed and changed an existing record. We can replace all the columns with a new value, as well as just one column or multiple columns.

We call it first UPDATE for its use . Then we write the table name. The name of the table we want to change. Then   we say SET . We enter the colon name = 'valueName' and we perform our operation.
Now let's explain them by decorating them with visuals.


In the image above, I have a table I created and the data I have added in this table.
Now I WANT TO UPDATE SURNAME AND PROVINCES IN THIS TABLE.
AREA LAST ANYWHERE in TURKEY" GET.
ANKARA"   IS EVERYWHERE IN THE PROVINCE .
Let's write our codes now.

SELECT * FROM contacts
UPDATE contacts 
SET lastname = "Turkey", il = 'Ankara'


What did we do here? With the select command, I first chose my table to make changes. Then I used the update command, that is, our update command. Then I said Set and then I wrote down the column names I wanted to change. I changed the last name and provincial columns. Now you will write which columns you want to change. Now let's look at the output of our code.

  As you can see that I have already mentioned my name field with Turkey. My province area was updated with ANKARA, which I mentioned. This is the Update process in Microsoft Sql Server. In the following lessons, we will also see Conditional updates. For now, this is good work for everyone.

Yorum Yap

Daha yeni Daha eski