MySQL Wildcards

MySQL Wildcards

MySQL Aliases

MySQL Aliases

MySQL Data Types

MySQL Data Types

MySQL Interview Questions

MySQL Interview Questions and Answers


MySQL Update Statement

The UPDATE statement allows you to modify or update the existing records in a table. We can use the UPDATE statement to change column values of a single row, a group of rows, or all rows in a table.

Note: One or more field can be updated altogether. You can add any condition to check before updating the record by using WHERE clause.

MySQL UPDATE TABLE Syntax

To update the existing record in table, use the following syntax:

Syntax

UPDATE tablename SET field1 = newvalue1, field2 = new-value2 [WHERE Condition]  

Parameters:

tablename: The table name from which you want to update.

Conditions: To add specific condition. The conditions parameter is optional.

MySQL UPDATE TABLE examples

The following MySQL statement to updating first name and last name for record having cellNo '2342323234' in tblCustomerLoan table:

Example

UPDATE tblCustomerLoan SET firstName = 'Sunil', lastName = 'Shetty' WHERE cellNo = 2342323234;

Note:

In the above example, we have updated first name and last name for the record having cellNo '2342323234' in existing table "tblCustomerLoan".

You can use MySQL Command Line Client to update record with specific condition in table. It will look like this:

Show UPDATE TABLE

You can check that the record has been updated based on given condition by the following query:

Example

SELECT * FROM tblCustomerLoan;  

You can use MySQL Command Line Client to show updated record from table. It will look like this: