• Home
  • SQL UPDATE Statement

    The SQL UPDATE statement is used to modify existing records in a database table. It allows you to change the values of one or more columns in one or more rows based on specified conditions.


    Here's the basic syntax of the UPDATE statement:

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

    In the above syntax:

    - `table_name` is the name of the table you want to update.
    - `column1`, `column2`, etc., are the columns you want to update.
    - `value1`, `value2`, etc., are the new values you want to set for the respective columns.
    - `WHERE` is an optional clause that specifies the condition(s) that must be met for the update to occur. If omitted, all rows in the table will be updated.


    Here's an example to illustrate the usage of the UPDATE statement:

    Let's say we have a table named "Employees" with columns "FirstName," "LastName," and "Salary." We want to update the salary of an employee with the last name "Smith" to $60,000. The query would be:

    UPDATE Employees
    SET Salary = 60000
    WHERE LastName = 'Smith';

    This query will modify the "Salary" column of the row(s) that satisfy the condition "LastName = 'Smith'", setting the value to $60,000.


    Remember to be cautious when using the UPDATE statement, as it can modify data in your database, and incorrect updates can result in unintended consequences. Always double-check your conditions and values before executing an UPDATE statement.



    About the Author



    Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

    We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc





     PreviousNext