The SQL UPDATE Query is used to modify the existing records in a table.
You can use WHERE clause with UPDATE query to update selected rows, otherwise all the rows would be
affected.
Syntax :-
The basic syntax of UPDATE query with WHERE clause is as follows :-
UPDATE table_name
SET column1 = value1, column2 = value2...., columnN = valueN
WHERE [condition];
You can combine N number of conditions using AND or OR operators.
Example :-
Consider the CUSTOMERS table having the following records :-
You can use WHERE clause with UPDATE query to update selected rows, otherwise all the rows would be
affected.
Syntax :-
The basic syntax of UPDATE query with WHERE clause is as follows :-
UPDATE table_name
SET column1 = value1, column2 = value2...., columnN = valueN
WHERE [condition];
You can combine N number of conditions using AND or OR operators.
Example :-
Consider the CUSTOMERS table having the following records :-
Following is an example, which would update ADDRESS for a customer whose ID is 6:
UPDATE CUSTOMERS
SET ADDRESS = 'Pune'
WHERE ID = 6;
Now, CUSTOMERS table would have the following records :-
If you want to modify all ADDRESS and SALARY column values in CUSTOMERS table, you do not need to use WHERE clause and UPDATE query would be as follows :-
UPDATE CUSTOMERS
SET ADDRESS = 'Pune', SALARY = 1000.00;
Now, CUSTOMERS table would have the following records :-



No comments:
Post a Comment