How to use the SQL UPDATE Statement

How to use the SQL UPDATE Statement


How to use the SQL UPDATE Statement

Learn how to use the SQL UPDATE Statement. This tutorial demonstrates how to write an UPDATE query with an easy to follow example.

SQL UPDATE Statement (and sample data):
https://www.techonthenet.com/sql/upda

SQL Tutorials:
https://www.techonthenet.com/sql/inde

Don’t forget to subscribe to our channel for more great SQL tutorials!

Visit us at: https://www.techonthenet.com
or follow us on:

Facebook: https://www.facebook.com/techonthenetcom
Twitter: https://twitter.com/tech_on_the_net
Pinterest: https://www.pinterest.com/techonthene


Content

0.02 -> The UPDATE statement (or commonly referred to as the "UPDATE query")
4.5 -> is the SQL statement that is used to update existing records in your database tables
9.38 -> The best way to understand the UPDATE statement is to look at an example
13.7 -> So let's get started
15.76 -> Here we have a table called customers containing the following data
19.86 -> Let's write an UPDATE statement that changes the first_name to Judy
23.68 -> where the customer_id value is equal to 8000
27.5 -> We'll start by entering UPDATE customers
30.84 -> This lets the database know that we want to write an UPDATE query
34.44 -> and change the records in the customers table
37.82 -> Next, we need to enter the SET keyword
40.62 -> This is where we enter the list of columns that we want to update
44.92 -> and the values that we want to update to
47.6 -> In this example, we'll enter first_name = 'Judy'
52.68 -> Now the query knows to set the first_name column to 'Judy' in the customers table
57.28 -> Notice that the value 'Judy' is enclosed in quotes since it is a string value
62.98 -> If you were to enter more than one column to update
65.96 -> you would comma separate any additional column/value pairs
70.16 -> The WHERE clause is optional
72.74 -> It is used to specify conditions that must be met for the records to be updated
77.3 -> If no conditions are provided, then all records in the customers table will be updated
82.66 -> Since you want to update only those records where the customer_id is equal to 8000
88.34 -> we will enter our WHERE Clause as follows
91.06 -> Now let's run our UPDATE statement and see what results we get
95.76 -> In this example, the database will return a message to let us know that one record has been updated
101.22 -> and if we look at the customers table
104.06 -> we should see that the first_name is now set to 'Judy' for customer_id 8000
109.6 -> This covers a simple example of how to use the SQL UPDATE statement
114.5 -> If you would like to see more UPDATE examples
116.86 -> or would like to download the sample date that we used for this tutorial
120.24 -> please visit our website at TechOnTheNet.com
123.16 -> You can also try the examples on our SQL editor on our website
127.44 -> Look for the "Try It" button next to each example
130.88 -> if you found our tutorial helpful, please leave a like on this video
134.7 -> and don't forget to subscribe to our YouTube channel for more great SQL tutorials

Source: https://www.youtube.com/watch?v=B6WCH3X9oyE