MySQL in a Nutshell (In a Nutshell (O'Reilly)) and over 2 million other books are available for Amazon Kindle . Learn more
  • RRP: £23.50
  • You Save: £0.53 (2%)
FREE Delivery in the UK.
Only 1 left in stock (more on the way).
Dispatched from and sold by Amazon.
Gift-wrap available.
MySQL in a Nutshell (In a... has been added to your Basket
+ £2.80 UK delivery
Used: Good | Details
Sold by paulmyo57
Condition: Used: Good
Comment: Ex-library book with usual stamps and markings. Has curling to bottom front pages, otherwise in good condition. Dispatch in 24 hours. See feedback for fast deliveries. All books sent in bubble wrap envelopes.
Trade in your item
Get a £2.59
Gift Card.
Have one to sell?
Flip to back Flip to front
Listen Playing... Paused   You're listening to a sample of the Audible audio edition.
Learn more
See all 2 images

MySQL in a Nutshell (In a Nutshell (O'Reilly)) Paperback – 25 Apr 2008

See all 4 formats and editions Hide other formats and editions
Amazon Price New from Used from
Kindle Edition
"Please retry"
"Please retry"
£12.52 £10.35
£22.97 FREE Delivery in the UK. Only 1 left in stock (more on the way). Dispatched from and sold by Amazon. Gift-wrap available.

Frequently Bought Together

MySQL in a Nutshell (In a Nutshell (O'Reilly)) + PHP in a Nutshell (In a Nutshell (O'Reilly))
Price For Both: £35.77

Buy the selected items together

Trade In this Item for up to £2.59
Trade in MySQL in a Nutshell (In a Nutshell (O'Reilly)) for an Amazon Gift Card of up to £2.59, which you can then spend on millions of items across the site. Trade-in values may vary (terms apply). Learn more

Product details

  • Paperback: 566 pages
  • Publisher: O'Reilly Media; 2 edition (25 April 2008)
  • Language: English
  • ISBN-10: 0596514336
  • ISBN-13: 978-0596514334
  • Product Dimensions: 15.2 x 2.9 x 22.9 cm
  • Average Customer Review: 4.2 out of 5 stars  See all reviews (4 customer reviews)
  • Amazon Bestsellers Rank: 446,791 in Books (See Top 100 in Books)
  • See Complete Table of Contents

More About the Author

Discover books, learn about writers, and more.

Product Description

About the Author

Russell Dyer is a freelance writer and currently the CurriculumManager at MariaDB Ab. He worked previously for six years at MySQL Ab. as their Knowledge Base Editor. He is the author of MySQL in a Nutshell ( and has writen articles for several magazines: Dev Zone (a MySQL publication), Linux Journal,, The Perl Journal, Red Hat Magazine, SysAdmin Magazine, Tech Republic, Unix Review, and He has also finished his first novel, "In Search of Kafka". More information on Russell, along with a list of his published articles with links to them, can be found on his web site at

Excerpt. © Reprinted by permission. All rights reserved.

Chapter 6 Date and Time Functions

The ability to record dates and times in a MySQL database is a very common requirement. This chapter presents the date and time functions for MySQL.

Date and time data comprises only numeric strings, so it can be stored in a regular character column. However, by using temporal datatype columns, you can use several built-in functions offered by MySQL. Currently, five temporal datatypes are available: date, time, datetime, timestamp, and year. The date column type is only for recording the date and uses the format yyyy-mm-dd. The time column type is for recording time in the format hhh:mm:ss. To record a combination of date and time, you can use the datetime column type: yyyy-mm-dd hh:mm:ss. The timestamp column is similar to datetime, but is a little limited in its range of allowable time: it starts at the Unix epoch time (i.e., 1970-01-01) and ends at the end of 2037. Finally, the year datatype is used only for recording the year in a column.

Incidentally, any function that calls for a date or a time datatype will also accept a combined datetime datatype. For more information on date and time datatypes, see Appendix A.

Validation of date strings is limited: MySQL makes sure that months range only from 0 to 12, and days range from 0 to 31. Therefore, a date such as February 30would be accepted. Version 5.0.2 of MySQL will offer more refined validation that would reject such a date.

At the end of this introduction is a listing of date and time functions, grouped by type of function. The bulk of this chapter consists of an alphabetical listing of date and time functions, with explanations of each. Many functions come with examples, along with a resulting display. For help in locating functions, see the index at the back of this book.

For the examples in this chapter, I used the scenario of a professional services firm (e.g., a law firm or an investment advisory firm) that tracks appointments and seminars in MySQL.

Date and Time Functions Grouped by Type

This section lists the functions according to their purpose: to retrieve a time, extract an element of one, or perform calculations on it.

Determining the Date and Time

Extracting and Formatting the Date and Time

Calculating and Modifying the Date and Time

Date and Time Functions in Alphabetical Order

The rest of the chapter lists each function in alphabetical order.

ADDDATE(date,INTERVAL value type)

This function adds the given interval of time to the date or time provided. This is an alias for DATE_ADD( ); see its definition for details and interval types.

UPDATE seminars
SET seminar_date = ADDDATE(seminar_date, INTERVAL 7 DAY)
WHERE seminar_date = '2004-12-15'';

This example postpones the seminar that was scheduled for December 15, 2004 to December 22—seven days later. As of Version 4.1 of MySQL, for adding days the second argument of the function may simply be the number of days (i.e., just 7 instead of INTERVAL 7 DAY). --This text refers to an alternate Paperback edition.

Inside This Book (Learn More)
Browse Sample Pages
Front Cover | Copyright | Table of Contents | Excerpt | Back Cover
Search inside this book:

What Other Items Do Customers Buy After Viewing This Item?

Customer Reviews

4.2 out of 5 stars
5 star
4 star
3 star
2 star
1 star
See all 4 customer reviews
Share your thoughts with other customers

Most Helpful Customer Reviews

1 of 1 people found the following review helpful By Lubo D. on 28 Jan. 2011
Format: Paperback
im currently studing IT on a degree course and as i had the same book borrowed from the school library, i knew it was written on high standard. even though i borrowed the newer version, i decided to buy this one - price decided it for me, but i can't say there is big difference in these two versions (the newer comes with couple new features built into the newer MySQL, but you still get all you need for building solid and powerful code in MySQL). i would definitely suggest buying the book - as a reference book it is published by O'Reilly and let's all be honest - they are the best ones for books of this kind. thanks
Comment Was this review helpful to you? Yes No Sending feedback...
Thank you for your feedback. If this review is inappropriate, please let us know.
Sorry, we failed to record your vote. Please try again
By alana on 12 April 2012
Format: Paperback Verified Purchase
This has had extensive use in the last few months, as I have been creating a web site from scratch. It is best used in conjunction with Google, as there are both formal documentation and a lot of examples available there.

There is an error on pages 32 and 33 - the TEXT_FIELDS function mentioned doesn't exist without additional plugins, that are not part of the standard mysql distribution.
Comment Was this review helpful to you? Yes No Sending feedback...
Thank you for your feedback. If this review is inappropriate, please let us know.
Sorry, we failed to record your vote. Please try again
Format: Paperback Verified Purchase
I might as well just have printed off the MySQL on-line documentation, this book really adds little. It's not an introduction for a novice and it doesn't provide real in-depth technical information for the advanced user, it's essentially a language reference. Handy to have lying around, but not what I was hoping for.
Comment Was this review helpful to you? Yes No Sending feedback...
Thank you for your feedback. If this review is inappropriate, please let us know.
Sorry, we failed to record your vote. Please try again
1 of 5 people found the following review helpful By James T on 16 Oct. 2010
Format: Paperback
I ordered this book mostly to refer to example SQL code, ranging from basic to complex queries. This book demonstrates and explains each example clearly (with drawn tables). Would definitely recommend it to those who wish to learn SQL. I received this item quickly and was amazed at the condition of the book. The item description warned of minor bookshelf wear but you could almost class the book as brand new. Extremely happy with it and would definitely purchase from the seller again.
1 Comment Was this review helpful to you? Yes No Sending feedback...
Thank you for your feedback. If this review is inappropriate, please let us know.
Sorry, we failed to record your vote. Please try again

Most Helpful Customer Reviews on (beta) 12 reviews
22 of 24 people found the following review helpful
you need a background in SQL 8 May 2005
By W Boudville - Published on
Format: Paperback
Well the book certainly seems to cover MySQL's features quite comprehensively. But, as it is a reference manual, it does not attempt to teach you MySQL or the theory of relational databases. For a given MySQL command, the book's explanation is succinct and useful. Provided you already have a background in the area. Much of the book's discussion is probably already available in equivalent form in the online help. But hardcopy is nice to have.

Going through the functions, what you might appreciate about MySQL is that many of these are generic SQL functions. If you come from any other SQL implementation, your background will be relevant to much of the book.
23 of 26 people found the following review helpful
MySQL and how to use it effectively! 6 Jan. 2006
By Rob Wehrli - Published on
Format: Paperback
The book is "A Desktop Quick Reference" just as billed on the cover. It is explicitly MySQL-centric and doesn't stray from that core message. It is extremely up-to-date considering the rapidity of movement in MySQL development progress.

I feel that its author, Russell Dyer is the kind of person who is easy to talk to and immediately be comfortable with based on his style and presentation in this book.

The content of this book is very well organized in keeping with the finest traditions at O'Reilly & Associates. There is an installation guide, tutorial, SQL syntax reference, MySQL built-in functions section(s), command-line utilities reference and programming languages API references for PERL, PHP and C. These API references demonstrate commonplace MySQL usage through clear, easy-to-read examples that make good sense.

It is a very comprehensive text that reads as easily as a favorite novel yet is concise enough to be your first "go-to" on MySQL issues you may face day-in and day-out. It is truly the "most advanced kingfisher" (cover animal) on the topic and, like the Pied kingfisher, it is lightweight and demonstrates keenly honed survival skills.

I use MySQL daily and I find it very useful and enjoyable. I don't want to become an SQL guru or even a DBA, as a programmer, I enjoy having MySQL In A Nutshell close at hand so that I can focus on writing code. Thank you Mr. Dyer (and the folks at O'Reilly) for a job well-done! I heartily recommend it to everyone using MySQL. The convenience of this publication clearly outweighs its cost. Newcomers and RDBMS "old-timers" will appreciate this book equally.
28 of 34 people found the following review helpful
Another Solid Nutshell Book 17 May 2005
By Larry - Published on
Format: Paperback
Ah, "Nutshell" books - you gotta love `em. Or maybe you don't. I won't get into the pros and cons of online documentation versus books because this subject has been rehashed ad infinitum. Truth is, there are pros and cons for both, and we each have our own reasons for our own preferences.

That being said, if you like book documentation - and "Nutshell" books in particular - then you will like this book. I happen to think it is a good idea to tear yourself away from the keyboard/screen every once in awhile, and the "Nutshell" books give you a good reason for doing so.

I'm not a SQL expert, so I liked the tutorial-flavored introductions at the beginning of each chapter, followed by the conversational tone of the clear and concise examples. I did not have this book when I first started programming using MySQL, and that's too bad because it could have saved me a lot of wasted time with its explanations of some of the more nefarious "gotchas" of the language.

I have but one criticism and one suggestion:

Criticism: The following APIs are covered at the end of the book: Perl, PHP, and C. I can see leaving out COBOL and Lisp (if there are even APIs for these languages), but Java? Granted, the Java interface to MySQL is well-documented in many places, but if you are discussing the *major* programming language APIs to MySQL then you should do just that.

Suggestion: The beginning of the book provides an introduction to MySQL via command-line instructions. I can see doing this, even though no one interacts with databases through the command line. What I think would be even more useful would be a brief discussion of the two tools that everyone does use: MySQL Administrator and MySQL Query Browser. A couple of chapters (along with some screen shots) of what they are, why we need them, where to get them, and how to use them would really make this book perfect. (If you don't forget that Java API chapter!)
2 of 2 people found the following review helpful
Great Reference 30 July 2010
By Darth Mortis - Published on
Format: Paperback Verified Purchase
I don't think a long, comprehensive review is needed here. This is a quick reference guide to have handy when you're working on a project or whatever. You won't learn MySQL from it but as long as you are already familiar with it, it serves as a great, quick reference, especially when you are utilizing keywords or routines that you don't normally use and therefore don't have in the forefront of your mind. If you need a bit of a field refresher, this works great!
7 of 9 people found the following review helpful
It does not cover MySQL 5 or later. 7 Jun. 2007
By Amazon Shopper - Published on
Format: Paperback Verified Purchase
It's a great reference but dated. If I had known that it only covers through version 4, I would not have purchased it.
Were these reviews helpful? Let us know