SQL Delete Statements

SQL DELETE allows you to remove data from your table(s).  It is imperative that you include a where clause in your delete statement, as experience has taught me the concequences of forgeting.

For the sake of argument, lets remove the same record we added back on the INSERT page.

nID

nLegs

strColor

strSize

strType

nWeight

 

          5                    4                  Purple             Medium           Kitchen              20

To do this we will use an DELETE command.  Again, once we have completed, we will want to execute a COMMIT;  If you have not reviewed the commit, head over to the UPDATE page.

DELETE FROM  <Table Name>

WHERE <Column Name> [= < > != BETWEEN NOT] <Column Name or Value> [AND/OR] [<Column Name> [= < > != BETWEEN NOT] etc.]

COMMIT;

DELETE FROM tblChair

WHERE nID = 5;

COMMIT;

Do not forget the quotes when dealing with text.  The result is of our delete is shown below.

nID

nLegs

strColor

strSize

strType

nWeight

1

0

Black

Big

Lounger

250

2

4

Brown

Little

Kitchen

50

3

3

Red

Medium

Kitchen

100

4

4

Blue

Huge

Stool

75

 

 

 

 

 

 

I hope you have enjoyed my rather simplistic tutorial on SQL, if you wish to explore more of this language, visit the Tutors page for some great links to other online self help guides.

FreeBSD Logo
Bouncing Badger Logo
NOF Logo