Time
7 hours 36 minutes
Difficulty
Beginner
CEU/CPE
3

Video Transcription

00:00
Hi. Welcome back to model threes, people Programming
00:02
where you are currently in less than one single statements. Sub lesson One point for the update statement. Now the ah, anything about the update statement is that is very similar to the select statement, except with a few different arrangements. In the select statement, we had select field names
00:21
from table name
00:23
where conditions are true
00:26
in an update statement, it's going to be a little different. It's gonna be
00:30
update table name
00:32
set column name, too. What do you want it to be? Where conditions are true.
00:37
So it's table columns conditions,
00:40
whereas a select statement is columns, tables, conditions.
00:45
So let's go ahead and make a couple changes that we can then fix with an update statement. Now, De Beber has a neat feature that when you're working with simple queries or just a specific table in ah, in general, you can actually just edit the values. Now, if you write a really complex quarry, you won't be able to just edit the values because the beaver won't be
01:06
as commented on what exactly you're trying to edit, but with just focusing on the user's table again, which, if we filter that down,
01:15
we can see that. That's this table right here from that axiomatic a database that we imported
01:19
and we can see that we've cleared out the user's where is approved equals one
01:26
company ideas, too,
01:26
from the user table.
01:29
So we have a bunch of ones. Let's go ahead and click into the column said it to zero. It inner.
01:34
We're just gonna change a few of them to zero.
01:38
So they are now disabled
01:41
and not 10 0
01:45
So now we click. Save
01:48
de Beber has
01:49
updated those for us. And if we run the statement again, we will see
01:53
these.
01:55
These folks disappear from the query results
01:59
and they are gone
02:00
now in this other career that I have open,
02:05
I'm selecting where the value of is approved is zero. So we should see
02:10
that these
02:13
folks that we just disabled should appear in this quarry
02:16
on There they are.
02:19
So we use D beaver to update those. We used an interface update those, but how would we write a query to update those? Well, it's not too bad. We would just click. New sequel editor,
02:30
we say updates
02:32
table name. We want to update the users
02:39
we wanna
02:42
sets
02:44
is approved
02:46
equal to one
02:47
where
02:51
company ideas, too,
02:53
and
02:54
is approved
02:57
is
02:59
zero.
03:01
So, again, we're updating this table.
03:05
We're setting this column to this value
03:07
where these conditions are true
03:13
and was going and run that
03:15
Andy burritos us. We updated four rows.
03:22
And if you go back, Thio
03:24
Well, I don't like him.
03:25
That's a different script that we go back to.
03:29
Our crew were selected. Where is approved? Zero will see that we had for,
03:35
uh, four rows of data. So now the rerun, this query, we should see that they have disappeared,
03:42
and sure enough, they have.
03:44
And if we ready ran the Cree where is approved is one. We should see
03:49
those guys pop back into the query,
03:51
and sure enough, they did.
03:53
So the update statement
03:57
is
03:58
can be summarized in this layout. It's update table name
04:02
set columns to the value where the conditions are true,
04:08
which is very similar to the select statement which was select columns
04:11
from the table where conditions are true.
04:15
So that brings this. Listen to a close. I hope you were able to get your updates, statements working and I will see you in the next video. Thank you.

Up Next

Introduction to SQL

This introductory SQL training teaches SQL core concepts that can be applied in professional environments. Once students complete this course, they will be able to query and interact with an SQL database, and know how to design database schemas.

Instructed By

Instructor Profile Image
Kitt Parker
Instructor