Microsoft Word - Sam's Teach Yourself MySQL in 21 Days - SAMS.doc

(singke) #1

To begin, you need a database that has tables you can export. You will find the Northwind sample
database on the CD-ROM included with this book. You will export files from this database to your
MySQL database.



  1. Open the database. You should see all the database objects—tables, queries,
    reports, and forms (see Figure 8.1).


Figure 8.1 The Northwind database.


  1. You are going to use the Orders and Customers tables. Open the Orders
    table; you will see the the dates are stored in dd-mm-yyyy format. This can be a
    problem when importing data into MySQL. MySQL dates are stored in yyyy-mm-
    dd. The easiest way to change this is in the Access database. Switch into Design
    mode and change the format of the dates to match that of MySQL.

  2. You are going to try to export the Orders table to the table with the same name
    in the MySQL database, but you notice some problems. The NorthWind Orders
    table is not as normalized and you table is. This is going to require you to do
    some manipulation to fit your database.

  3. The plan is to create a query that will export the data you want to a comma-
    delimited text file. To do this, click the Queries icon on the left side of the
    database objects window (see Figure 8.2).


Figure 8.2 The Northwind query objects.


  1. You are going to design a query that pulls the data you need to fill the columns in
    your table. From the query window, click New. The New Query dialog box will
    open. Click Design View.

  2. The Show Table window will appear. Select the tables that contain the data you
    need here. You need to select the Customers and Orders tables. The Orders
    table contains the customer name, not the Customer_ID, so you need to pull
    both tables into your query.

  3. After you have selected the tables, you need to select the fields to display in your
    query. Looking at your selection, you can see some of the fields that are in the
    Meet_A_Geek database, but not all of them. This means that you will have to use
    the LOAD DATA INFILE command instead of the mysqlimport utility because
    you have already created your table in the MySQL database. Select the following
    fields:

Free download pdf