In our last episode we started building up our
online bookshop database, with tables for publishers, authors,
formats and books. At the moment we only have one book in
there, so before we go too far, lets add a few more:
INSERT INTO `book` VALUES
( NULL, 'The Big Score', 2, 4, 1, '2007-01-01', 9781741752236, 29.95 ),
( NULL, 'Split', 3, 2, 1, '2003-01-01', 0732268133, 29.95 );
So what is this NULL thing, and why have I used it? If you
remember we set the first field to an auto_increment id.
Because we don't want to supply a value for this, but let the
database create the next value, we need to give a value that
indicates we want this to happen. For this instance, NULL
is the value to use. We must supply a value because we
didn't restrict our insert by supplying a …
[Read more]