Update Query in MySQL || MySQL Update Query
×

MySQL Update Data

3858

When you work with the databases, you need to make some changes into the existing data. So, If you want to modify the existing data in the table then,"UPDATE" statement is used for this.

Update Query in MySQL:

UPDATE table_name
SET field1='value',
field2='value2'
WHERE condition;

WHERE

  1. table_name is the name of the table which you want to modify.
  2. field1 and field2 is the name of columns in the table.
  3. value1 and value2 is the values of fields1 and fields2 respectively.
  4. Condition is the specified condition through which you define the particular rows in which you want to make changes. If you make forget the WHERE condition, it will update all rows into the table.


MySQL Update Data Example:

<?php
$conn=mysqli_connect("localhost","root","","databasename"); // create connection wit the database
$sql="UPDATE students
SET division='First'
WHERE ROLL_NO=20";
// students is table name and division is field name
$result= mysqli_query($conn,$sql);
echo "Data Updated Successfully";
?>


Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments