To update specific rows in a table in SQL, you can use the following syntax:
sqlUPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;
Here, table_name
is the name of the table, column1
, column2
, etc. are the names of the columns you want to update, and value1
, value2
, etc. are the new values for the columns. The WHERE
clause is used to specify the conditions for the update and ensures that only the rows that meet the conditions are updated.
For example, to increase the salary of all employees with an age
greater than 30 by 10%:
sqlUPDATE employees SET salary = salary * 1.10 WHERE age > 30;
To delete specific rows from a table in SQL, you can use the following syntax:
sqlDELETE FROM table_name WHERE condition;
Here, table_name
is the name of the table, and the WHERE
clause is used to specify the conditions for the deletion and ensures that only the rows that meet the conditions are deleted.
For example, to delete all employees with an age
less than 25:
sqlDELETE FROM employees WHERE age < 25;
Social Plugin