
The syntax of the statement for deleting records in a table is as follows:
DELETE FROM <table_name> [WHERE <search_condition>]
The above statement deletes the records that satisfy <search_condition>
in the WHERE clause. If there is no WHERE clause, all the records will be deleted.
See the following examples (click here to see the contents
of the original table). For Microsoft Foxpro, remember to set DELETED on before
querying after deletion. Otherwise, the results of deletion cannot be seen.
Delete all records with the marks of CS lower than 50. |
DELETE FROM s6a WHERE
cs < 50 |
After execution, the table becomes:
class_num |
stud_id |
name |
email |
clc |
ue |
phy |
pm |
cs |
1 |
92114 |
Chan Wai Man, Raymond |
s92114@sample.edu.hk |
64 |
55 |
70 |
64 |
59 |
2 |
92133 |
Chow Chi Ling |
clchow@example.com |
70 |
62 |
62 |
59 |
70 |
3 |
94302 |
Fung Ching Man, Mandy |
mandyfung@example.com |
72 |
50 |
42 |
59 |
60 |
4 |
91131 |
Hung Wai Ming |
s91131@sample.edu.hk |
52 |
48 |
55 |
39 |
59 |
5 |
92153 |
Leung King |
kleung@example.com |
40 |
50 |
51 |
40 |
60 |
6 |
92211 |
Poon Kwok Fai |
kwokfai@testing.com.hk |
59 |
60 |
70 |
77 |
75 |
7 |
91194 |
Sung Hing Wah, Patrick |
patricksung@example.com |
70 |
72 |
81 |
69 |
70 |
8 |
97602 |
Tang Wing Chi |
s97602@sample.edu.hk |
80 |
79 |
70 |
72 |
69 |
10 |
93211 |
Yeung Chun |
cyeung@testing.com.hk |
69 |
80 |
77 |
60 |
52 |
11 |
96374 |
Lai Fung Chun |
s96374@sample.edu.hk |
78 |
75 |
69 |
65 |
61 |
12 |
94412 |
Chan Lai Yin |
cly@testing.com.hk |
43 |
59 |
53 |
61 |
60 |
13 |
98832 |
Man Fook Wing |
fwman@testing.com.hk |
55 |
77 |
34 |
40 |
51 |
14 |
95343 |
Chung Kwok Fai, Fred |
fredchung@example.com |
72 |
62 |
53 |
47 |
50 |
15 |
97233 |
Lee Lai May |
maylee@testing.com.hk |
67 |
71 |
56 |
60 |
55 |
|
Delete all the records in the table s6a. |
DELETE FROM s6a |
After execution, there is no record in
the table s6a. |
