An update query is used to update records in the table.
For this query command, we will use the given table as an example.
id | first_name | last_name | |
1 | Aman | Singh | aman@gmail.com |
2 | Rakesh | Singh | rakesh@gmail.com |
Update records change first_name to Amit which has id 1
UPDATE users SET first_name="Amit" WHERE id=1;
id | first_name | last_name | |
1 | Amit | Singh | aman@gmail.com |
2 | Rakesh | Singh | rakesh@gmail.com |
Update multiple fields
UPDATE users SET first_name="Ramesh", last_name="Kumar" WHERE id=2;
id | first_name | last_name | |
1 | Amit | Singh | aman@gmail.com |
2 | Ramesh | Kumar | rakesh@gmail.com |