Advertisement

Responsive Advertisement

SQL Update Statement with PHP

 


The SQL UPDATE Statement

The UPDATE statement is used to modify the existing records in a table.

UPDATE Syntax

UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;

Note: Be careful when updating records in a table! Notice the WHERE clause in the UPDATE statement. The WHERE clause specifies which record(s) that should be updated. If you omit the WHERE clause, all records in the table will be updated!



SQL UPDATE

The SQL commands (UPDATE and DELETE) are used to modify the data that is already in the database. The SQL DELETE command uses a WHERE clause.

SQL UPDATE statement is used to change the data of the records held by tables. Which rows is to be update, it is decided by a condition. To specify condition, we use WHERE clause.

The UPDATE statement can be written in following form:

  1. UPDATE table_name SET [column_name1= value1,... column_nameN = valueN] [WHERE condition]  

Let's see the Syntax

  1. UPDATE table_name  
  2. SET column_name = expression  
  3. WHERE conditions  

Let's take an example: here we are going to update an entry in the source table.

SQL statement:

  1. UPDATE students  
  2. SET User_Name = 'beinghuman'  
  3. WHERE Student_Id = '3'  

Source Table:

Student_IdFirstNameLastNameUser_Name
1AdaSharmasharmili
2RahulMauryasofamous
3JamesWalkerjonny



Post a Comment

0 Comments