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;
- table_name is the name of the table which you want to modify.
- field1 and field2 is the name of columns in the table.
- value1 and value2 is the values of fields1 and fields2 respectively.
- 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"; ?>