codesnout.com

SQL DELETE

Google Ads

SQL DELETE


SQL Sample Code - SQL DELETE.

The statement below deletes values in a specified row.

DELETE FROM table_name
WHERE “Condition” ;

Always include the WHERE clause otherwise all columns will be updated

Once executed the DELETE statement action is not reversible.

If you do want to delete all rows from a table use the syntax below;

DELETE FROM table_name;

Alternatively you can use

DELETE * FROM table_name ;

See the SQL samples section below for an explanation of the DELETE statement.


What does the SQL DELETE statement do?

The SQL DELETE statement simply deletes the specified value(s) of a record in a table.


Sample – SQL DELETE

In this SQL sample we will use the database table ‘tblCompany’.

Company_ID CompanyName Address Town Sales
1 SQL Sample 1 Sample St Hamburg 10000
2 SQL Code Land 2 Code Rd Hamburg 20000
3 Sample Code World 66 SQL St Curry 18000
4 SQL Reference Ltd 34 Reference St Pisa 17000

In the database table above we want to delete the Curry World’s record.

Use the SELECT statement below:

DELETE FROM tblCompany
WHERE CompanyName=’Curry World';

The table of results will look like this:

Company_ID CompanyName Address Town Sales
1 SQL Sample 1 Sample St Hamburg 10000
2 SQL Code Land 2 Code Rd Hamburg 20000
4 SQL Reference Ltd 34 Reference St Pisa 21000

 


Related SQL Sample Code:


About Us | Privacy Policy | Contact Us | ©2010 Thunderousity Information Management Solutions | www.autosnout.com - Car Performance Statistics Website Utilising SQL | SQL Blog |

SQL Home | SQL Intro | SQL SELECT Statement | DISTINCT | WHERE | SQL Wildcards | AND OR | IN | BETWEEN | LIKE | ORDER BY | GROUP BY | TOP | ALIAS | DELETE | INSERT | UPDATE | CREATE DATABASE | CREATE TABLE | ALTER | INNER JOIN | FULL JOIN | LEFT JOIN | RIGHT JOIN | UNION | CONSTRAINTS | NOT NULL| Aggregate Functions | SUM | AVG | COUNT | MAX | MIN | FIRST | LAST | GROUP BY | HAVING | LIMIT | Microsoft Access Data Types | MySQL Data Types | SQL Server Data Types | ASCII HTML Reference Sheet |