반응형
UPDATE
기존 데이터의 값을 변경하는 SQL
insert into cats
(name,breed,age)
values
('Ringo','Tabby',4),
('Cindy','Maine Coon',10),
('Dumbledore','Maine Coon',11),
('Egg','Persian',4),
('Misty','Tabby',13),
('George Michael','Ragdoll',9),
('Jackson','Sphynx',7);
select * from cats;

breed가 Tabby인 고양이의 종을, Shorthair로 변경
( set은 변경될 값을 적어주고, where는 조건문이라고 이해하면 쉽다. )
update cats
set breed = 'Shorthair'
where breed = 'Tabby';

고양이 이름이 Misty인 고양이의 나이를 14로 변경
update cats
set age = 14
where name = 'Misty';

이름이 'Jackson'인 고양이의 이름을 Jack으로 변경
update cats
set name = 'Jack'
where name = 'Jackson';

반응형
'TOOL > MySQL' 카테고리의 다른 글
| MySQL - 데이터 중복 제거 (Distinct) (0) | 2022.05.16 |
|---|---|
| MySQL - DELETE (0) | 2022.05.15 |
| MySQL - Select ( slicing / concat / replace / reverse / char_length / upper / lower ) (0) | 2022.05.15 |
| MySQL - Data Insert (0) | 2022.05.14 |
| MySQL - MySQL Workbench Create Table (0) | 2022.05.14 |