Reading view

There are new articles available, click to refresh the page.

Update data on table

UPDATE statement allows you to update data in one or more columns of one or more rows in a table.

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

In this syntax:

  • First, specify the name of the table that you want to update data after the UPDATE keyword.
  • Second, specify columns and their new values after SET keyword. The columns that do not appear in the SET clause retain their original values.
  • Third, determine which rows to update in the condition of the WHERE clause
Code:
UPDATE company SET salary = salary * 2
WHERE salary = 150000;

The WHERE clause is optional. If you omit the WHERE clause, the UPDATE statement will update all the column values in the table.

Code:
UPDATE company SET salary = salary * 2

Summary :
  • Use the UPDATE statement to update data in one or more columns of a table.
  • Specify a condition in a WHERE clause to determine which rows to update data.
  • Use the RETURNING clause to return the updated rows from the UPDATE statement

Reference :

Update data on table

UPDATE statement allows you to update data in one or more columns of one or more rows in a table.

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

In this syntax:

  • First, specify the name of the table that you want to update data after the UPDATE keyword.
  • Second, specify columns and their new values after SET keyword. The columns that do not appear in the SET clause retain their original values.
  • Third, determine which rows to update in the condition of the WHERE clause
Code:
UPDATE company SET salary = salary * 2
WHERE salary = 150000;

The WHERE clause is optional. If you omit the WHERE clause, the UPDATE statement will update all the column values in the table.

Code:
UPDATE company SET salary = salary * 2

Summary :
  • Use the UPDATE statement to update data in one or more columns of a table.
  • Specify a condition in a WHERE clause to determine which rows to update data.
  • Use the RETURNING clause to return the updated rows from the UPDATE statement

Reference :

❌