UPDATE Command in SQL
SQL UPDATE Command
UPDATE Command in SQL
UPDATE command is used to modify the the table data (Records) in SQL. UPDATE command used with SET Key word. For example if you have a table with some record and you want to make some changes in that records, then you can use UPDATE command with SET keyword. With UPDATE command you can also use the WHERE clause for make changes on some specific recode.
Syntax is :
UPDATE Table-Name
SET Coulm1=vlaue1 ,column2=value2......
WHERE Condition ;
For example we have a following table
TABLE_A
| Name | Course_Title | Contact No | City |
| Mr. Muneer | DIT | 999999 | NULL |
| Mr. Naweed | PDP | 222222 | NULL |
| Mr.tauqeer | DIT | 333333 | NULL |
| Mr. Jalil | DIT | 222222 | NULL |
In above table there is no city name is given in all record. if you want insert the same city name in each record then you can use the following statement:
UPDATE Table-A
SET City='Lahore' ;
The above statement set the city name Lahore of the all records.
if you want set a Unique city name of each record then you can use the following statement:
UPDATE Table-A
SET City='Lahore' ;
WHERE Name='Mr. Muneer' ;
The above statement set the city name Lahore only for Mr. Muneer.