<< previous page   --   table of contents   --   next page >>
| | | | | | | |
  • Return to Table of Contents
  • Table of Contents

    1. General Information
    2. MySQL Installation
    3. Tutorial Introduction
    4. Database Administration
    5. MySQL Optimisation
    6. MySQL Language Reference
    7. MySQL Table Types
    8. MySQL APIs
    9. Extending MySQL

    Chapter 3:  Tutorial Introduction 153 mysql> SELECT * FROM pet; +----------+--------+---------+------+------------+------------+ | name | owner   | species | sex   | birth | death | +----------+--------+---------+------+------------+------------+ | Fluffy | Harold | cat | f | 1993-02-04 | NULL | | Claws | Gwen | cat | m | 1994-03-17 | NULL | | Buffy | Harold | dog | f | 1989-05-13 | NULL | | Fang | Benny   | dog | m | 1990-08-27 | NULL | | Bowser | Diane   | dog | m | 1998-08-31 | 1995-07-29 | | Chirpy | Gwen | bird | f | 1998-09-11 | NULL | | Whistler | Gwen | bird | NULL | 1997-12-09 | NULL | | Slim | Benny   | snake | m | 1996-04-29 | NULL | | Puffball | Diane   | hamster | f | 1999-03-30 | NULL | +----------+--------+---------+------+------------+------------+ This form of  SELECT  is useful if you want to review your entire table,  for instance,  after you've just loaded it with your initial dataset.  As it happens, the output just shown reveals an error in your data le:  Bowser appears to have been born after he died!  Consulting your original pedigree papers, you nd that the correct birth year is 1989, not 1998. There are are least a couple of ways to x this:    Edit the le `pet.txt' to correct the error, then empty the table and reload it using DELETE  and  LOAD DATA: mysql> SET AUTOCOMMIT=1;   # Used for quick re-create of the table 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 Pu ball.    Fix only the erroneous record with an UPDATE statement: mysql> UPDATE pet SET birth = "1989-08-31" WHERE name = "Bowser"; As shown above, it is easy to retrieve an entire table.  But typically you don't want to do that, particularly when the table becomes large.  Instead, you're usually more interested in answering a particular question, in which case you specify some constraints on the informa- tion you want.  Let's look at some selection queries in terms of questions about your pets that they answer. 3.3.4.2  Selecting Particular Rows You can select only particular rows from your table.  For example, if you want to verify the change that you made to Bowser's birth date, select Bowser's record like this: mysql> SELECT * FROM pet WHERE name = "Bowser"; +--------+-------+---------+------+------------+------------+ | name | owner | species | sex   | birth | death | +--------+-------+---------+------+------------+------------+ | Bowser | Diane | dog | m | 1989-08-31 | 1995-07-29 | +--------+-------+---------+------+------------+------------+ The output con rms that the year is correctly recorded now as 1989, not 1998.
     

    Customer Support CentreMySQL Reference Manual

    Web Hosting Services
    UNIX WEB HOSTING
    SUPPORT & FAQ's
    TERMS OF USE
    Domain Services
    DOMAIN REGISTRATION
    MANAGE YOUR ACCOUNT
    SUPPORT & FAQ's
    TERMS OF USE
    SITE MAP
    Home
    Hosting Plans | Domain Registration | About Us | Contact Us | Site Map
    Terms of Use | Privacy Policy | Guarantees
    Merchant Accounts

    SpiritHost - web hosting for spiritual and education sites
    SpiritHit.com - Religious and Spiritual Portal
  • Return to Table of Contents
  • Back to top

  • Web Hosting: Manuals & FAQ's

    1. Unix-Based Web Hosting
    2. Unix Dedicated Servers
    3. Windows Dedicated Servers
    4. CuteFTP User’s Guide
    5. CuteHTML User’s Guide
    6. WS_FTP Pro User's Guide
    7. Miva Order User's Guide
    8. Miva Merchant User's Guide