What Is SQL UPDATE Statement And How To Use


The SQL UPDATE statement allows you to update a single record or multiple records in a table.

The syntax for the SQL UPDATE statement is:
UPDATE table SET column = expression WHERE predicates;

Simple example:
UPDATE employees SET name = 'Tommy' WHERE name = 'Dev';
This SQL UPDATE statement would update all employee names in the employees table from Dev to Tommy.

Updating multiple columns example:
An SQL UPDATE example where you might want to update more than one column with a single SQL UPDATE statement.
UPDATE employees SET name = 'Tom', city = 'Delhi' WHERE name = 'Jack';
When you want to update multiple columns, you can do this by separating the column/value pairs with commas.

This SQL UPDATE statement would update the employee name to "Tom" and city to "Delhi" where the name of the employee is "Jack".

HELP: What Is SQL SELECT Statement And How To Us

HELP: What Is SQL INSERT Statement And How To Us

    Blogger Comment
    Facebook Comment
 
Copyright © 2013. New Techie - All Rights Reserved
Template Created by ThemeXpose