MySQL Tutorial

Abstract

This is the MySQL Tutorial from the MySQL 5.7 Reference Manual.

For legal information, see the Legal Notices.

For help with using MySQL, please visit either the MySQL Forums or MySQL Mailing Lists, where you can discuss your issues with other MySQL users.

For additional documentation on MySQL products, including translations of the documentation into other languages, and downloadable versions in variety of formats, including HTML and PDF formats, see the MySQL Documentation Library.

Licensing information—MySQL 5.7.  This product may include third-party software, used under license. If you are using a Commercial release of MySQL 5.7, see this document for licensing information, including licensing information relating to third-party software that may be included in this Commercial release. If you are using a Community release of MySQL 5.7, see this document for licensing information, including licensing information relating to third-party software that may be included in this Community release.

Licensing information—MySQL Cluster.  This product may include third-party software, used under license. If you are using a Community release of MySQL Cluster NDB 7.5, see this document for licensing information, including licensing information relating to third-party software that may be included in this Community release.

Document generated on: 2016-11-04 (revision: 49755)


Table of Contents

Preface and Legal Notices
1 Tutorial
2 Connecting to and Disconnecting from the Server
3 Entering Queries
4 Creating and Using a Database
4.1 Creating and Selecting a Database
4.2 Creating a Table
4.3 Loading Data into a Table
4.4 Retrieving Information from a Table
4.4.1 Selecting All Data
4.4.2 Selecting Particular Rows
4.4.3 Selecting Particular Columns
4.4.4 Sorting Rows
4.4.5 Date Calculations
4.4.6 Working with NULL Values
4.4.7 Pattern Matching
4.4.8 Counting Rows
4.4.9 Using More Than one Table
5 Getting Information About Databases and Tables
6 Using mysql in Batch Mode
7 Examples of Common Queries
7.1 The Maximum Value for a Column
7.2 The Row Holding the Maximum of a Certain Column
7.3 Maximum of Column per Group
7.4 The Rows Holding the Group-wise Maximum of a Certain Column
7.5 Using User-Defined Variables
7.6 Using Foreign Keys
7.7 Searching on Two Keys
7.8 Calculating Visits Per Day
7.9 Using AUTO_INCREMENT
8 Using MySQL with Apache