일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- PANDAS
- Text mining
- PROJECT
- error
- Default X points
- polynomial regression
- line width
- break
- AS
- __init__
- Github
- For loops
- line color
- data distribution
- variables
- SQL
- machine learning
- Text Analytics
- pie charts
- multiple lines
- matplotlib
- MySQL
- matplotlib.pyplot
- iterates
- continue
- train/test
- self parameter
- Python
- Else
- start exercise
- Today
- Total
Data Science Explorer
[Basic Grammar] SQL UPDATE Statement 본문
The UPDATE statement is used to modify the existing records in a table.
- UPDATE Syntax
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
** Tip: Notice the WHERE clause in the UPDATE statement.**
- UPDATE Table
Example
Update the first customer (CustomerID = 60) with a new contact person and a new city.
UPDATE Customers
SET ContactName = 'Pearl', City = 'Seoul'
WHERE CustomerID = 60;
- UPDATE Multiple Records
It is the WHERE clause that determines how many records will be updated.
Example
Update the BrandName to "Kim's" for all records where city is "Salt Lake City":
UPDATE Brand
SET BrandName = 'Kim's'
WHERE City = 'Salt Lake City';
** WARNING: If you omit the WHERE clause, ALL records will be updated!! **
Exercises
1. Update the Price column of all records in the "Products" table. Set the Price to $29.99 for all products.
UPDATE Products
SET Price = $29.99 ;
2. Update the EmployeeName column of all records in the "Employees" table. Set the EmployeeName to 'John Doe' for all employees.
UPDATE Employees
SET EmployeeName ='John Doe';
3. Update the "ProductCategory" to 'Electronics' for all products in the "Products" table that have a "Price" greater than $100.
UPDATE Products
SET ProductCategory = 'Electronics'
WHERE Price > $100;
'SQL' 카테고리의 다른 글
[Basic Grammar] SQL MIN() and MAX() Functions (0) | 2023.10.14 |
---|---|
[Basic Grammar] SQL DELETE Statement (0) | 2023.10.14 |
[Basic Grammar] SQL NULL Values (0) | 2023.10.14 |
[Basic Grammar] SQL INSERT INTO Statement (1) | 2023.10.14 |
[Basic Grammar] SQL NOT Operator (0) | 2023.10.13 |