MySQL - Update Query
Update statement is used to modify the existing records in a table.
SYNTAX
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
First we will assume a table with details:
StudentId | StudentName | ParentName | Address | PostalCode | City |
---|---|---|---|---|---|
1 | Sanjana | jagannath | Banjara Hills | 500046 | Hyderabad |
2 | Shivanatini | Praveen | Camel street | 700096 | Kolkata |
NOW,lets check out how the UPDATE query works:
UPDATE studentrecord
SET StudentName = 'Anasya'
WHERE StudentID = 1;
The result will be displayed as follows:
StudentId | StudentName | ParentName | Address | PostalCode | City |
---|---|---|---|---|---|
1 | Anasya | jagannath | Banjara Hills | 500046 | Hyderabad |
2 | Shivanatini | Praveen | Camel street | 700096 | Kolkata |
UPDATE studentrecord
SET Address = 'Hayath nagar',
City = 'Noida'
WHERE StudentID = 2;
The result will be displayed as follows:
StudentId | StudentName | ParentName | Address | PostalCode | City |
---|---|---|---|---|---|
1 | Anasya | jagannath | Banjara Hills | 500046 | Hyderabad |
2 | Shivanatini | Praveen | Hayath nagar | 700096 | Noida |
MySQL - Grant_ Revoke Privilege
posted on 2019-11-26 23:15:04 - mysql Tutorials