Low cost ecommerce web development India flash website design

Inserting Data into a Table

Our database is created and our table is built; all that's left is to put some actual

jokes into our database. The command for inserting data into our database is

called, appropriately enough, INSERT. There are two basic forms of this command:

mysql>INSERT INTO table_name SET

-> columnName1 = value1,

-> columnName2 = value2,

-> ...

->;

mysql>INSERT INTO table_name

-> (columnName1, columnName2, ...)

-> VALUES (value1, value2, ...);

So, to add a joke to our table, we can choose from either of these commands:

mysql>INSERT INTO Jokes SET

->JokeText = "Why did the chicken cross the road? To get to

"> the other side!",

->JokeDate = "2000-04-01";

mysql>INSERT INTO Jokes

->(JokeText, JokeDate) VALUES (

->"Why did the chicken cross the road? To get to the other

"> side!",

->"2000-04-01"

->);

Note that in the second form of the INSERT command, the order in which you

list the columns must match the order in which you list the values. Otherwise,

the order of the columns doesn't matter, as long as you give values for all required

43

Inserting Data into a Table

fields. Now that you know how to add entries to a table, let's see how we can

view those entries.

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