Viewers: in countries Watching now:
MySQL is by far the most popular database management system for small- to medium-sized web projects. In this course, Bill Weinman provides clear, concise tutorials that guide you through creating and maintaining a MySQL database of your own. Bill explores the basic syntax, using SQL statements to create, insert, update, and delete data from your tables. He also covers creating a new database from scratch, as well as data types, transactions, subselects, views, and stored routines. Plus, learn about the multi-platform PHP PDO interface that will help you connect your database to web applications.
The update statement is used to change data in existing rows in a table. In this lesson, I'll be using the Scratch Database. And, I'm continuing with the test table that I created in the previous lesson. So if we say, SELECT * FROM test;, we can see the state of this. And we'll go ahead and we'll update a row. The update statement uses a where clause, just like the select statement. So, sometimes I like to start with a select statement with a where clause, like this, where a equals two.
And then I know that my where clause is. Selecting just the row that I want to change. This prevents me from accidentally updating rows that I don't intend to update. So for example, here I can say, UPDATE test, SET C equals Extra Funny. And we use that where clause that I've already typed and presumably debugged. And then after this I can say select star from test, and we can see the result. So there it is.
Sense of humor, extra funny. So you see that the. Update statement is used to change the data. I use the set clause here with the expression, the assignment expression to set the column that I'm interested in changing, and I use the where clause to select just the row or rows that I'm interested in updating. So, if I wanted to update it again I could change it again here I could say even funnier. And select go and you see there we have even funnier there in our results.
I can also set the value to null if I want and this effectively removes a value because remember. Null is the absence of value so I can use the key word null like this, and now we have a null there in our c column for a equals two. And you'll learn about null later in this chapter. So the update statement is used to change the data in particular columns in a table. You can select which rows are affected by using the where clause. Again, I'm going to leave this test table here for now and we'll be using it in the next lesson to learn about delete.
There are currently no FAQs about MySQL Essential Training.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.