Start reading MySQL Cookbook on the free Kindle Reading App or on your Kindle in under a minute. Don't have a Kindle? Get your Kindle here.
This title is not currently available for purchase
Sorry, this item is not available in
Image not available for
Image not available

To view this video download Flash Player


MySQL Cookbook [Kindle Edition]

Paul DuBois
4.6 out of 5 stars  See all reviews (33 customer reviews)

Pricing information not available.

Free Kindle Reading App Anybody can read Kindle books—even without a Kindle device—with the FREE Kindle app for smartphones, tablets and computers.

To get the free app, enter your email address or mobile phone number.


Amazon Price New from Used from
Kindle Edition --  
Paperback $36.99  
Shop the new
New! Introducing the, a hub for Software Developers and Architects, Networking Administrators, TPMs, and other technology professionals to find highly-rated and highly-relevant career resources. Shop books on programming and big data, or read this week's blog posts by authors and thought-leaders in the tech industry. > Shop now

Book Description

Along with MySQL's popularity has come a flood of questions about solving specific problems, and that's where this Cookbook is essential. Designed as a handy resource when you need quick solutions or techniques, the book offers dozens of short, focused pieces of code and hundreds of worked-out examples for programmers of all levels who don't have the time (or expertise) to solve MySQL problems from scratch.

The new edition covers MySQL 5.0 and its powerful new features, as well as the older but still widespread MySQL 4.1. One major emphasis of this book is how to use SQL to formulate queries for particular kinds of questions, using the mysql client program included in MySQL distributions. The other major emphasis is how to write programs that interact with the MySQL server through an API. You'll find plenty of examples using several language APIs in multiple scenarios and situations, including the use of Ruby to retrieve and format data. There are also many new examples for using Perl, PHP, Python, and Java as well.

Other recipes in the book teach you to:

  • Access data from multiple tables at the same time
  • Use SQL to select, sort, and summarize rows
  • Find matches or mismatches between rows in two tables
  • Determine intervals between dates or times, including age calculations
  • Store images into MySQL and retrieve them for display in web pages
  • Get LOAD DATA to read your data files properly or find which values in the file are invalid
  • Use strict mode to prevent entry of bad data into your database
  • Copy a table or a database to another server
  • Generate sequence numbers to use as unique row identifiers
  • Create database events that execute according to a schedule
  • And a lot more

MySQL Cookbook doesn't attempt to develop full-fledged, complex applications. Instead, it's intended to assist you in developing applications yourself by helping you get past problems that have you stumped.

Editorial Reviews Review

Good programming--which is to say, programming that yields both efficient code and a profitable life for the programmer--depends on not reinventing the wheel. If someone else has solved the problem you're facing (and someone almost always has), you'd be foolish to waste your energy figuring out your own solution. MySQL Cookbook presents solutions to scores of problems related to the MySQL database server. Readers stand a good chance of finding a ready-made solution to problems such as querying databases, validating and formatting data, importing and exporting values, and using advanced features like session tracking and transactions. Paul DuBois has done a great job assembling efficient solutions to common database programming problems, and teaches his readers a lot about MySQL and its attendant APIs in the process.

DuBois organizes his cookbook's recipes into sections on the problem, the solution stated simply, and the solution implemented in code and discussed. The implementation and discussion sections are the most valuable, as they contain the command sequences, code listings, and design explanations that can be transferred to outside projects. The main gripe readers will have about MySQL Cookbook is that the author, in his effort to cover the range of MySQL-friendly programming languages, uses different languages in his solutions to various problems. You'll see a Perl solution to one programming challenge (Perl, in fact, is the most frequently used language, followed by PHP), a Python fix for the next, and a Java sample after that. Readers have to hope that they find a solution in the language they're working with, or that they're able to transliterate the one DuBois has provided. It's usually not a big problem. --David Wall

Topics covered: How to make MySQL databases do your bidding--in terms of queries, table manipulation, data formatting, transactions, and Web interfaces--through the database server's command line interfaces and (more importantly) through the MySQL APIs of Perl, PHP, Java, and Python. Particularly excellent coverage deals with formatting dates and times, management of null values, string manipulation, and import/export techniques.


"...MySQL Cookbook tells you exactly how to solve literally hundreds of problems that you are likely to encounter in getting a MySQL database solution up and running." - Computer Trade Shopper, November 2003

Product Details

  • File Size: 1756 KB
  • Print Length: 980 pages
  • Simultaneous Device Usage: Unlimited
  • Publisher: O'Reilly Media; 2 edition (May 10, 2012)
  • Language: English
  • ASIN: B0093SZ51E
  • Text-to-Speech: Enabled
  • X-Ray:
  • Lending: Not Enabled
  • Amazon Best Sellers Rank: #565,480 Paid in Kindle Store (See Top 100 Paid in Kindle Store)
  •  Would you like to give feedback on images?.

Customer Reviews

Most Helpful Customer Reviews
37 of 38 people found the following review helpful
5.0 out of 5 stars The only MySQL book needed for programming my web sites December 9, 2004
I built several web sites using PHP/MySQL and the only two books I use day-to-day are "MySQL Cookbook" and "PHP Cookbook".

If you're already somewhat familiar with MySQL, this book is a great reference for the SQL and database manipulation you already know how to do. In addition, the examples push the envelope of what is possible with MySQL making it a good learning tool for becoming truly expert.

Some of the information in the book I found useful includes:

- simplifying complex SQL using temporary tables.

- using FULLTEXT searches (similar to pattern matching but more efficient and easier to code when you're looking for the same text in several columns at the same time).

- effective use of LEFT JOIN's for finding rows in one table that don't have a match in another table.

- effective use of LAST_INSERT_ID( fieldName + 1 ) for transactionally updating a numeric field without using transactions and without locking a table.

- numbering output rows using SQL variables (select @rownum := @rownum + 1; (see chapter 13.9))

I really can't say enough good things about this book. It's comprehensive, easy to read and just plain awesome.
Comment | 
Was this review helpful to you?
17 of 18 people found the following review helpful
4.0 out of 5 stars A Hand-on guide to MySQL May 20, 2003
By A Customer
There are many databases out there. MySQL is one of the better ones. It's a free (for personal use) database system which can be easily integrated into a web application on virtually any system. It has supports most of the standard feature found in most database system and has quiet a few features unique to MySQL. This particular book is a good reference for the experienced user as well as for new comers and as an added bonus even covers MySQL 4.0.
This is book was my first introduction to O'Reilly's cookbook series. It provides solutions to some of the most common challenged faced by the particular subject being covered (in this case MySQL). I thoroughly enjoyed it and was quiet impressed with it. Too many technical books simply introduce the concept without relating it to real world applications.
This particular book introduces all of the most basic concepts of database manipulation (table creation, data insertion, data deletion, data update). As well as writing simple and advanced SQL statements to retrieve data. It approaches database design using 4 of the most popular languages (Perl, PHP, Python and Java). These are only a few of the many possible languages which can be used to manipulate a MySQL database.
MySQL cookbook touches on a variety of different topics which I don't have the space or time to cover in detail, but here is a list of them:
* Handeling duplicates
* MySQL on the Web
* Processing Web input with MySQL
* Using MySQL-based Web Session Management
One of my favorite topics covered in the book is the idea of storing binary data such as images within a database. Although not ideal for most cases (unless you need fast access to a vast array of images), just the idea of it has a certain kewlness effect.
Well, overall I give it 4 out of 5 stars. It needs to touch slightly more on the basic concepts of databases, and it can become the only book you'll ever need for MySQL.
Comment | 
Was this review helpful to you?
13 of 14 people found the following review helpful
5.0 out of 5 stars a nice addition to O'Reilly's Cookbook series April 13, 2003
As an experienced Oracle DBA I had a need to learn about MySQL for the development of the FmPro Migrator utility to migrate FileMaker databases to MySQL. This book enabled me to quickly learn how to perform tasks in MySQL which are equivalent to what I would perform with Oracle. Congratulations to O'Reilly and Paul DuBois for continuing the fine tradition of Cookbook series books.
Comment | 
Was this review helpful to you?
23 of 28 people found the following review helpful
5.0 out of 5 stars Excellent All-Around Guide To MySQL Programming April 5, 2004
I am an experienced web developer and recently started using Perl with MySQL to build database-driven CGI applications.
MySQL Cookbook by Paul DuBois turned out to be a valuable reference resource.
While the title mentions only MySQL, the book provides a great deal of solutions (and code) for using MySQL with Perl, PHP, Python and Java. If you are familiar with any of these computer languages, this book and MySQL manual is all you need to start building applications with MySQL-compatible database backend.
Comment | 
Was this review helpful to you?
13 of 15 people found the following review helpful
5.0 out of 5 stars Incredibly Useful November 11, 2002
This book is well done, clearly written and sensibly organized. I read the same author's New Riders Book on MySQL and found it similarly useful; but if you've already got all the theory down, this may well be the only MySQL book you'll need. Wish I'd had it a few years ago.
Comment | 
Was this review helpful to you?
11 of 13 people found the following review helpful
This book should be useful for anybody who uses MySQL, ranging from individuals who want to use a database for personal projects such as a blog or Wiki, to professional database and web developers. The book should also appeal to people who do not now use MySQL, but would like to. For example, it should be useful if you want to learn about databases but realize that a "big" database system such as Oracle isn't the best choice as a learning tool. The following paragraphs summarize each chapter to give you an overview of the book's contents.

Chapter 1, Using the mysql Client Program, describes how to use the standard MySQL command-line client. In addition, the chapter discusses other ways to use mysql, such as how to number output lines or make long lines more readable, how to generate various output formats, and how to log mysql sessions.

Chapter 2, Writing MySQL-Based Programs, demonstrates the basic elements of MySQL programming: how to connect to the server, issue queries, retrieve the results, and handle errors. It also discusses how to handle special characters and NULL values in queries, how to write library files to encapsulate code for commonly used operations, and describes various ways to gather the parameters needed for making connections to the server.

Chapter 3, Selecting Data from Tables, covers several aspects of the SELECT statement, which is the primary vehicle for retrieving data from the MySQL server: specifying which columns and rows you want to retrieve, performing comparisons, dealing with NULL values, and selecting one section of a query result.

Chapter 4, Table Management, covers table cloning, copying results into other tables, using temporary tables, and checking or changing a table's storage engine.
Read more ›
Comment | 
Was this review helpful to you?
Most Recent Customer Reviews
5.0 out of 5 stars Portable class room reference
Already had the paper copy but needed a reference in the class room for students as they work through their projects. Read more
Published 3 months ago by Jeff O'Byrne
1.0 out of 5 stars Why the high ratings?
I bought this book a couple of years ago on the strength of its Amazon ratings. Over this time, I haven't been able to use it even once. Read more
Published 5 months ago by Groundhog Day
5.0 out of 5 stars Different and awesome
This book takes a different approach than most mysql books. It is definitely more about tweaking than learning but is awesome for what it is.
Published 6 months ago by Jeffrey Smith
5.0 out of 5 stars Very useful tool!
This book provides very useful ideas and examples for any developer. It is definitely worth having in your programming library.
Published 8 months ago by Fred
4.0 out of 5 stars Ask Felgall - Book Review
This book is huge and like the other books in the cookbook series the primary purpose of the book is to provide real solutions to real life problems. Read more
Published on November 23, 2011 by Stephen Chapman
5.0 out of 5 stars Good and Fast!
This is a decent service. The quality of the book is exactly the same as described and the delivery is only two weeks as a instant local purchase! Good job.
Published on March 17, 2011 by NotSure
5.0 out of 5 stars My son the computer tech was right--once again.
I need to learn about MySQL for my small business. My son the computer tech said this was the book I needed to get me up to speed quickly. He was right. Read more
Published on August 6, 2009 by Amazon Customer
4.0 out of 5 stars Quickstart to MySQL Development
I really enjoy cookbooks because of their no nonsense organization. This MySQL book exactly fits that description. Read more
Published on November 13, 2008 by Sean P. Hull
5.0 out of 5 stars Teasure Trove of MySQL Recipes
At 900+ pages this book addresses a lot of common SQL tasks. And that's what a good cookbook should do. Read more
Published on September 27, 2008 by Larry
5.0 out of 5 stars excellent resource
This book is
-a great resource for those looking to implement various mysql functions
-a great resource for database programmers
-a trove of information on powerful... Read more
Published on April 10, 2008 by Prego
Search Customer Reviews
Search these reviews only

More About the Authors

Discover books, learn about writers, read author blogs, and more.

What Other Items Do Customers Buy After Viewing This Item?


There are no discussions about this product yet.
Be the first to discuss this product with the community.
Start a new discussion
First post:
Prompts for sign-in

Look for Similar Items by Category