Low cost ecommerce web development India flash website design
Deleting Stored Data
The deletion of entries in SQL is dangerously easy, which, if you haven't noticed
yet, is a recurring theme. Here's the command syntax:
mysql>DELETE FROM table_name WHERE conditons;
So to delete all chicken jokes from your table, you'd use the following query:
mysql>DELETE FROM Jokes WHERE JokeText LIKE "%chicken%";
One thing to note is that the WHERE clause is actually optional. You should be
very careful, however, if you leave it off, as the DELETE command will then apply
to all entries in the table. This command will empty the Jokes table in one fell
swoop:
mysql>DELETE FROM Jokes;
Scary, huh?
Summary
There's a lot more to the MySQL database system and the SQL language than
the few basic commands we've looked at here, but these commands are by far
the most commonly used. So far we've only worked with a single table. To realize
the true power of a relational database, we'll also need to learn how to use multiple
tables together to represent potentially complex relationships between database
entities.
We'll cover all this and more in Chapter 5, where we'll discuss database design
principles, and look at some more advanced examples. For now, though, we've
accomplished our objective, and you can comfortably interact with MySQL using
the command line interface. In Chapter 3, the fun continues as we delve into the
PHP server-side scripting language, and use it to create dynamic Web pages. If
you like, you can practice with MySQL a little before you move on, by creating
a decent-sized Jokes table — this knowledge will come in handy in Chapter 4!
47
Deleting Stored Data
website designer freelance ASP PHP ecommerce web developer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110