Home     SQL Basic     Contact Us     Site Map    

SQL BASIC

SQL SELECT

SQL WHERE

SQL DISTINCT

SQL AND

SQL OR

SQL NOT

SQL ORDER BY

SQL IN

SQL BETWEEN

SQL LIKE

SQL ALIAS

SQL AGGREGATE

>SQL COUNT

>SQL SUM

>SQL MAX

>SQL MIN

>SQL AVG

SQL GROUP BY

SQL HAVING

SQL INSERT

SQL UPDATE

SQL DELETE

SQL SELECT INTO

SQL CREATE DATABASE

SQL CREATE TABLE

SQL DROP TABLE

SQL DROP DATABASE

SQL CREATE INDEX

SQL PRIMARY KEY

SQL FOREIGN KEY

SQL ALTER TABLE

SQL TRUNCATE TABLE

SQL JOIN

SQL INNER JOIN

SQL OUTER JOIN

SQL CROSS JOIN

SQL UNION

SQL UNION ALL

SQL INTERSECT



SQL DELETE

The SQL DELETE Clause is used to delete rows in a table.
With some condition being set with the DELETE clause, all data that meet the condition will be deleted.

DELETE is not limited to one row at a time. We may delete any or all rows that apply to our conditional together.

The DELETE clause syntax:

DELETE FROM [TABLE NAME]
WHERE [COLUMN NAME] = [CONDITION]


EXAMPLE :

We can try to DELETE the records for Player Kenny in the table below.

Table GameScores

PlayerNameDepartmentScores
JasonIT3000
IreneIT1500
JaneMarketing1000
DavidMarketing2500
PaulHR2000
JamesHR2000
VivianMarketing2500
KennyHR2300

SQL statement :

DELETE FROM GameScores
WHERE PlayerName = 'Kenny'

After execute the SQL command. The table will look like like this. As we can see the record for Kenny already Deleted.

Table GameScores
PlayerNameDepartmentScores
JasonIT3000
IreneIT1500
JaneMarketing1000
DavidMarketing2500
PaulHR2000
JamesHR2000
VivianMarketing2500

If you wish to DELETE all rows inside a table.

The SQL Statement will be like this:

DELETE FROM GameScores