100 Days of SQL

sql

Day 77- SQL SET

In SQL, the SET keyword is used to update the values of one or more columns in a table. The basic syntax of an UPDATE statement with SET keyword is as follows:

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

Here, table_name is the name of the table to update, column1, column2, etc. are the names of the columns to update, value1, value2, etc. are the new values for the corresponding columns, and condition is an optional condition to filter the rows that will be updated.

For example, suppose we have a table called “employees” with columns “id”, “name”, “salary”, and “department”. To update the salary of all employees in the “sales” department by a fixed percentage, we can use the following query:

UPDATE employees
SET salary = salary * 1.1
WHERE department = 'sales';

This will update the “salary” column of all rows in the “employees” table where the “department” column is equal to “sales” by multiplying the current value by 1.1.