The SQL Server UPDATE Query is utilized to alter the current records in a table.
You can utilize WHERE condition with UPDATE inquiry to refresh chosen pushes in any case all the lines would be influenced.
Syntax
Following is the essential sentence structure of UPDATE question with WHERE provision −
UPDATE table_name
SET column1 = value1, column2 = value2...., columnN = valueN
WHERE [condition];
You can consolidate N number of conditions utilizing AND OR administrators.
Example
Consider the CUSTOMERS table having the accompanying records −
ID NAME AGE ADDRESS SALARY
1 Ramesh 32 Ahmedabad 2000.00
2 Khilan 25 Delhi 1500.00
3 kaushik 23 Kota 2000.00
4 Chaitali 25 Mumbai 6500.00
5 Hardik 27 Bhopal 8500.00
6 Komal 22 MP 4500.00
7 Muffy 24 Indore 10000.00
Following order is a model, which would refresh ADDRESS for a client whose ID is 6 −
UPDATE CUSTOMERS
SET ADDRESS = 'Pune'
WHERE ID = 6;
Clients table will presently have the accompanying records −
ID NAME AGE ADDRESS SALARY
1 Ramesh 32 Ahmedabad 2000.00
2 Khilan 25 Delhi 1500.00
3 kaushik 23 Kota 2000.00
4 Chaitali 25 Mumbai 6500.00
5 Hardik 27 Bhopal 8500.00
6 Komal 22 Pune 4500.00
7 Muffy 24 Indore 10000.00
In the event that you need to adjust all ADDRESS and SALARY segment esteems in CUSTOMERS table, you don't have to utilize WHERE proviso. UPDATE question would be as per the following −
UPDATE CUSTOMERS
SET ADDRESS = 'Pune', SALARY = 1000.00;
Clients table will presently have the accompanying records.
ID NAME AGE ADDRESS SALARY
1 Ramesh 32 Pune 1000.00
2 Khilan 25 Pune 1000.00
3 kaushik 23 Pune 1000.00
4 Chaitali 25 Pune 1000.00
5 Hardik 27 Pune 1000.00
6 Komal 22 Pune 1000.00
7 Muffy 24 Pune 1000.00