By 25/02/2016 1 Comments

What Is Update Statement In SQL?

  • The UPDATE statement updates a existing record/row in a database table.
  • In most situations the WHERE clause is used with UPDATE statement because the WHERE clause specifies which record to be updated. If WHERE class is not be specified that the all records/rows will be updated in database table.
  • Use WHERE class with UPDATE statement (recommended).
  • Use unique ID with WHERE clause when UPDATE any record (recommended).
  • The value of multiple columns of a single record/row can be updated with UPDATE statement.

Syntax:

UPDATE table_name
SET column1=value1,column2=value2,column3=value3,...
WHERE column_name=value;

Example-1: Update Multiple Columns Of Same Record

UPDATE tbl_users
SET user_name = "demo user 1", role = "super admin";
WHERE id = 1;

Example-2: Update Only Single Column Of Same Record

UPDATE tbl_users
SET user_name = "demo user 2"
WHERE id = 1;

Example-3: Use AND Operator

UPDATE tbl_users
SET user_name = "demo user 3"
WHERE id = 1
AND role = "super admin";

Example-4: Update All Records Without WHERE clause (not recommended)

UPDATE tbl_users
SET user_name = "demo user all", role = "user";





Next Tutorial →


← Previous Tutorial


Posted in: Sql

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .