Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Update Statement in SQL

Update Statement in SQL

The UPDATE statement in SQL is used to modify existing records in a table by changing one or more column values.


Key Points:

  • You specify the table to update.

  • Use the SET clause to assign new values to columns.

  • Optionally use a WHERE clause to update only specific rows.

  • Without WHERE, all rows in the table are updated!


Syntax

UPDATE table_nameSET column1 = value1,    column2 = value2,    ...WHERE condition;
  • WHERE condition filters which rows to update.

  • Multiple columns can be updated in one statement.


Example

Update a single row

UPDATE EmployeesSET Salary = 75000WHERE EmployeeID = 101;

Update multiple columns and multiple rows

UPDATE EmployeesSET Salary = Salary * 1.1,  -- 10% raise    Title = 'Senior Developer'WHERE Department = 'IT';

Important Notes

  • Always use WHERE unless you want to update every row.

  • You can use expressions and subqueries in SET values.

  • Some databases support RETURNING to show updated rows after execution.


If you want, I can help with examples for specific SQL databases or advanced UPDATE scenarios!

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql