×

  PHP

Introduction Getting Started Data Types Operators Conditional Statements Loops Functions Arrays Include Files GET and POST

  Mysql

Data Base Concepts Mysql Talking to Mysql

  PHP & Mysql

Connect DB Mysql insert Mysql select Mysql update Mysql delete
XAMPP Lite S/W

PHP MySQL UPDATE Query

UPDATE is the SQL command used to modify the contents of one or more columns in an existing record or set of records.

Basic UPDATE syntax:

UPDATE table_name SET column1='new value', 
column2='new value2' [WHERE some_condition_is_true]

The guidelines for updating a record are similar to those used when inserting a record: The data you’re entering must be appropriate to the data type of the field, and you must enclose your strings in single or double quotes.

To update the status of the fruit to ripe, use

UPDATE student SET age = 10;
UPDATE student SET class = '5th';

Conditional UPDATEs

Making a conditional UPDATE means that you are using WHERE clauses to match specific records. Using a WHERE clause in an UPDATE statement is just like using a WHERE clause in a SELECT statement. All the same comparison and logical operators can be used, such as equal to, greater than, OR, and AND.

UPDATE student SET class = '5th' WHERE RollNumber = 3;

Example 1: Download View


Example 2: Download View