SQL-Update Query

To update data in a table in SQL, you can use the UPDATE statement. Here is an example of how to update the salary of all employees to 50000: SQL-Update Query

UPDATE employees
SET salary = 50000;

You can also update specific rows based on a condition using a WHERE clause:

UPDATE employees
SET salary = 55000
WHERE age > 30;

This will update the salary of all employees whose age is greater than 30 to 55000.

You can also update multiple columns at once:

Example: SQL-Update Query

UPDATE employees
SET salary = 55000, age = age + 1;

This will update the salary of all employees to 55000 and increase their age by 1.

You can also update a column based on the value of other columns using the SET clause:

Example: SQL – Update Query

UPDATE employees
SET salary = salary * 1.1
WHERE age > 30;

This will increase the salary of all employees whose age is greater than 30 by 10%.

You can also update a table based on a select statement:

Example:

UPDATE employees
SET salary = (SELECT salary FROM employees_backup WHERE employees_backup.id = employees.id);

This will update the salary of all employees based on the salary column of the employees_backup table, where the id of the employees_backup table matches the id of the employees table.

Please note that you need to have appropriate permissions to update data in a table, otherwise you will get an error message.

SQL-Update Query

SQL-Update Query SQL-Update Query SQL-Update Query