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 DELETE
The DELETE statement is used to delete existing records in a table. It means you can use the WHERE clause with a DELETE query to delete the selected rows, otherwise all the records would be deleted.
Syntax:
DELETE FROM table_name WHERE condition;
Example Database:
This is customers table.
id | name | Location |
---|---|---|
1 | Kailash | Delhi |
2 | Amit | Haryana |
3 | Siddarth | Noida |
4 | Vikas | Noida |
DELETE Query
Example: The following code has a query, which will DELETE a customer, whose id is 3.
Syntax:
DELETE FROM customers WHERE id = 3;
Result:
id | name | Location |
---|---|---|
1 | Kailash | Delhi |
2 | Amit | Haryana |
4 | Vikas | Noida |
Delete All Records
Example: If you want to delete all records (rows) in a table without deleting the table. This means that the table structure, attributes, and indexes will be intact:
Syntax:
DELETE FROM customers;
Result:
id | name | Location |
---|
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