SQL Update

HTML
CSS
C#
SQL

SQL Update

The SQL commands UPDATE are used to modify the data that is already in the database. The SQL DELETE command uses a WHERE clause.

SQL UPDATE statement is used to change the data of the records held by tables. Which rows are to be updated, is decided by a condition. To specify the condition, we use the WHERE clause.

UPDATE Syntax

UPDATE table_name
SET column1 = value1, column2 = value2, …
WHERE condition;

EXAMPLES:

UPDATE Customers
SET ContactName=’Juan’
WHERE Country=’Mexico’;

Update Warning!

Be careful when updating records. If you omit the WHERE clause, ALL records will be updated!

Example

UPDATE Customers
SET ContactName=’Juan’;

SQL, which stands for “Structured Query Language,” is a special language that helps you chat with databases. It’s like having a conversation with a database. Imagine you’re talking to your computer, but instead of speaking English, you use SQL to ask questions and get information from the database.

Asking Questions: SQL is like a detective that can find specific information from a database. You can ask it to find and show you particular data, like names of people in a certain department:

SHOW ME the names of people in the IT department.

Changing Stuff: SQL isn’t just for reading data; it’s also for making changes. You can use it to add new things, update existing things, or remove stuff from the database. For example:

ADD a new person named John Doe to the list of customers.

Creating Databases and Tables: Think of SQL as a builder. You can use it to make new databases and decide how tables inside those databases should look. It’s like designing the blueprint for your data house:

BUILD a table for products with spaces for ID, name, and price.

Controlling Who Does What: SQL lets you decide who can enter the data house and who can’t. It’s like having keys to a room, and you can decide who gets a key.

Making Procedures and Views: SQL is also good at creating plans and nice views. It can make lists or charts to show data in a neat way.

SQL is not just another language; it’s the boss of data management. Here’s why it’s important:
Everyone Understands It: SQL is like a universal language for databases. It works with many types of databases, so you don’t need to learn a new language for each one.
It’s Fast: SQL is like a speedy racer. It can find information quickly, even if there’s a lot of data.
Keeps Data Safe: SQL is like a security guard. It makes sure only the right people can see and change the data.
Works for Big and Small: SQL is like a flexible tool. It’s great for small businesses and big companies with lots of data.

To sum it up, SQL is like your best buddy when it comes to dealing with data. It helps you talk to databases easily and do all sorts of important tasks.

Course Video

1.Create a 5 row customer table with customer id, name, address, email, budget and update the budget to 1200 where customer id is 3

Output Before Update

Output After Update

2.Create a table of sales with 5 column and insert data in the column and update product name where  ID is  3,5,9 in the table.

Output before update
Output after update on sale_id 3,5,9

3. write a query to Update personId = 1001 on sales.Customer table where customerID = 691, 701, 420 use ADVENTURE2019 database in SQL server

Output before update
Output after Update

4. Write sql query to update title= ‘sir’ where BusinessEntityID in (25,26) on person.person table use ADVENTURE2019 database in SQL server.

Output before Update
Output After Update

5.write a sql query to update bonus = 10000 where BusinessEntityID is 275,276,277 on sales.salesperson table  use

ADVENTURE2019 database in SQL server.

Output before update
Output after update