SQL Tutorial
What is SQL SQL SELECT SQL SELECT DISTINCT SQL WHERE SQL INSERT SQL UPDATE SQL DELETE SQL AND, OR & NOT Clause SQL ORDER BY SQL LIKE Clause SQL IN Operator SQL BETWEEN Operator SQL MAX() and MIN() SQL COUNTSQL JOIN
SQL JOIN SQL INNER JOIN SQL LEFT JOIN SQL RIGHT JOIN SQL FULL OUTER JOINSQL UPDATE
This statement is to modify/update the existing records in a table. You can use the WHERE clause with the UPDATE query to update the selected rows, otherwise all the rows would be affected.
Syntax:
UPDATE table_name SET column1 = value1, column2 = value2 WHERE condition;
Example Database:
This is customers table.
id | name | Location |
---|---|---|
1 | Kailash | Delhi |
2 | Amit | Haryana |
3 | Siddarth | Noida |
4 | Vikas | Noida |
UPDATE Table
The following query will update the location for a customers whose id number is 2 in the table.
Syntax:
UPDATE customers SET location = 'Gurgaon' WHERE id = 1;
Result:
id | name | Location |
---|---|---|
1 | Kailash | Gurgaon |
2 | Amit | Haryana |
3 | Siddarth | Noida |
4 | Vikas | Noida |
UPDATE Multiple Records
If you want to modify multiple column like- name and the location column values in the customers table, you need to use the WHERE clause as the UPDATE query would be enough as shown in the following code block.
Syntax:
UPDATE customers SET name='Hemant', location='Goa' WHERE id = 1;
Result:
id | name | Location |
---|---|---|
1 | Hemant | Goa |
2 | Amit | Haryana |
3 | Siddarth | Noida |
4 | Vikas | Noida |
SEARCH POST HERE
Support Us
Subscribe My YouTube Channel
Join Our Telegram Channel & Support Eachother
CATEGORIES
INTERVIEW QUESTIONS
POPULAR POSTS
Elevenstech Web Tutorials
Elevenstech Web Tutorials helps you learn coding skills and enhance your skills you want.
As part of Elevenstech's Blog, Elevenstech Web Tutorials contributes to our mission of “helping people learn coding online”.
Read More
Newsletter
Subscribe to get the latest updates from Elevenstech Web Tutorials and stay up to date