content_image/762594.jpg
statement. Suppose that Diane gets a new hamster named “Puffball.”  You could add a new record using an INSERT  statement like this: 

mysql> INSERT INTO pet VALUES (’Puffball’,’Diane’,’hamster’,’f’,’1999-03-30’,NULL); 

String and date values are specified as quoted strings here. Also, with INSERT , you can insert NULL directly to represent a missing value. You do not use \N  like you do with LOAD DATA . 

From this example, you should be able to see that there would be a lot more typing involved to load your records initially using several INSERT  statements rather than a single LOAD DATA  statement. 

## 3.3.4 Retrieving Information from a Table 

The SELECT  statement is used to pull information from a table. The general form of the statement is: 

SELECT what_to_select FROM which_table WHERE conditions_to_satisfy ; 

what_to_select  indicates what you want to see. This can be a list of columns, or *  to indicate “all columns.” which_table  indicates the table from which you want to retrieve data. The WHERE  clause is optional. If it is present, conditions_to_satisfy  specifies one or more conditions that rows must satisfy to qualify for retrieval. 

## 3.3.4.1 Selecting All Data 

The simplest form of SELECT  retrieves everything from a table: 

mysql> SELECT * FROM pet; 

<img src='content_image/762594.jpg'>

This form of SELECT  uses * , which is shorthand for “select all columns.”  This is useful if you want to review your entire table, for example, after you’ve just loaded it with your initial data set. For example, you may happen to think that the birth date for Bowser doesn’t seem quite right. Consulting your original pedigree papers, you find that the correct birth year should be 1989, not 1979. 

There are at least two ways to fix this: 

•Edit the file pet.txt  to correct the error, then empty the table and reload it using DELETE  and LOAD DATA : 

mysql> DELETE FROM pet; mysql> LOAD DATA LOCAL INFILE ’pet.txt’ INTO TABLE pet; 

However, if you do this, you must also re-enter the record for Puffball. 

•Fix only the erroneous record with an UPDATE  statement: 

mysql> UPDATE pet SET birth = ’1989-08-31’ WHERE name = ’Bowser’; 

