Programming Books C Java PHP Python Learn more Browse Programming Books
SQL Cookbook (Cookbooks (O'Reilly)) and thousands of other textbooks are available for instant download on your Kindle Fire tablet or on the free Kindle apps for iPad, Android tablets, PC or Mac.
Buy New
  • List Price: $39.95
  • Save: $14.29 (36%)
FREE Shipping on orders over $35.
In Stock.
Ships from and sold by
Gift-wrap available.
Add to Cart
Trade in your item
Get a $4.44
Gift Card.
Have one to sell? Sell on Amazon
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

SQL Cookbook (Cookbooks (O'Reilly)) Paperback – December 23, 2005

ISBN-13: 978-0596009762 ISBN-10: 0596009763 Edition: 1st

Buy New
Price: $25.66
39 New from $18.99 29 Used from $10.93
Rent from Amazon Price New from Used from
"Please retry"
"Please retry"
$18.99 $10.93


Frequently Bought Together

SQL Cookbook (Cookbooks (O'Reilly)) + Learning SQL + SQL Pocket Guide
Price for all three: $62.28

Buy the selected items together
  • Learning SQL $24.29
  • SQL Pocket Guide $12.33

Customers Who Bought This Item Also Bought

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

Product Details

  • Series: Cookbooks (O'Reilly)
  • Paperback: 636 pages
  • Publisher: O'Reilly Media; 1 edition (December 23, 2005)
  • Language: English
  • ISBN-10: 0596009763
  • ISBN-13: 978-0596009762
  • Product Dimensions: 9.1 x 6.9 x 1.4 inches
  • Shipping Weight: 2.3 pounds (View shipping rates and policies)
  • Average Customer Review: 4.6 out of 5 stars  See all reviews (69 customer reviews)
  • Amazon Best Sellers Rank: #19,555 in Books (See Top 100 in Books)

Editorial Reviews

Book Description

Query Solutions and Techniques for Database Developers

About the Author

Anthony Molinaro is a SQL developer and database administrator with many years experience in helping developers improve their SQL queries. SQL is particular passion of Anthony's, and he's become known as the go-to guy among his clients when it comes to solving difficult SQL query problems. He's well-read, understands relational theory well, and has nine years of hands-on experience solving tough, SQL problems. Anthony is particularly well-acquainted with new and powerful SQL features such as the windowing function syntax that was added to the most recent SQL standard.

More About the Author

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

Customer Reviews

The book: SQL Cookbook by Anthony Molinaro, is an outstanding book.
I still recommend using a "generic SQL" book to learn the basics, but this should literally be ordered at the same time.
M. Schwarz
For each problem, the book illustrates the solution and the rationale behind it.

Most Helpful Customer Reviews

66 of 68 people found the following review helpful By Rob Wehrli on January 19, 2006
Format: Paperback
This book is just fantastic. One really needs to read the inside cover pages to see what this book doesn't try to do. The relevant elements are:

Non-political (on several SQL-specific fronts)

Non-Pure ANSI (portability versus vendor-specific features)

Non-platform (I couldn't find a mention of a particular platform)

Basically, the book focuses on how to accomplish numerous SQL tasks using SQL and those features found on some of the top RDBMS vendors' products. It is selective in that the focus is constrained to MS SQL (platform obvious, but not mentioned that I could find) Server, DB2, MySQL, PostgresSQL and Oracle. I think that this well represents at least the 80/20 rule of who's running what RDBMS.

The book is a set of recipes for (usually) each of these platforms. Each recipe is a code-demonstrated "how-to" for accomplishing the given task. This is perfect for those who don't want to become DBAs and focus on learning "too" much about SQL, rather, want to use an example in their code to make it do the right thing.

The book is very well written and finished. It is a joy to read.

The one detraction that I can think of is that it would be nice to see all of the examples online at O'Reilly's web site so that we could "play around with them" somewhat without having to enter the database table contents and all of the SQL by hand. It "ain't that hard," but who's got the time to do it? I think that having the code available with the book would make it an excellent training tool for newcomers to SQL and those switching to a different product such as going from Oracle or MS SQL to MySQL or PostgresSQL. However, as it is, the book is a 4.5 stars product. If you're interested solely in MySQL, check out the MySQL Cookbook from O'Reilly.
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
Format: Paperback
Ultimately, the goal of this book is to give you a glimpse of what can be done using SQL outside of what is considered the typical SQL problem domain. This text is unique in that the target audience is wide, incorporating all levels of SQL programmers as well as those who are completely unfamiliar with SQL.

Both complex and simple solutions are provided, and solutions for five different vendors are available when a common solution does not exist. These five databases are DB2 v.8, Oracle Database 10g (with the exception of a handful of recipes, the solutions will work for Oracle8i Database and Oracle9i Database as well), PostgreSQL 8, SQL Server 2005 and MySQL 5. All of the examples are built around a small set of tables containing employee data. This helps the reader get familiar with the example data, so that, having become familiar with the data, you can focus on the technique that each recipe illustrates.

Chapter 1, Retrieving Records, introduces very simple queries. Examples include how to use a WHERE clause to restrict rows from your result set, providing aliases for columns in your result set, using an inline view to reference aliased columns, using simple conditional logic, limiting the number of rows returned by a query, returning random records, and finding NULL values. Most of the examples are very simple, but some of them appear in later more complex recipes, so it's a good idea to read this chapter if you're relatively new to SQL or aren't familiar with any of the examples listed for this chapter.

Chapter 2, Sorting Query Results, introduces recipes for sorting query results. The ORDER BY clause is introduced and is used to sort query results.
Read more ›
2 Comments 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
43 of 43 people found the following review helpful By M. Schwarz on May 9, 2007
Format: Paperback
It doesn't take long to learn the basics of SQL. Once you start to do multi-table joins and you get to sub-selects and outer joins you can almost convince yourself you are an expert. Trust me. You aren't. I've read at least ten books on using SQL. This is the first one to blow my horizons away and open a completely new landscape.

The "recipies" are well explained and almost entirely practical and useful. This book showed me dozens of things I did not ever think of using SQL for, even though I have the BNF for SQL pretty much in my head after more than 18 years of being a practicing programmer.

Before this book I used to recommend "generic" SQL books to students and newbies because such books apply to virtually all SQL databases and it can be harmful for one to use a specific "dialect" (such as Oracle or SQL Server) that won't port to other SQL databases. I would urge people to learn "generic" SQL. You can always add the features of you specific dialect, but it is hard to give up features you assume will be in all dialects.

This book neatly avoids that problem by providing dialect-specific sections when you can or must code differently for a particular database. Even better, they explain the differences and the pros and cons of those differences. So this book can even be an aid to selecting the "right" database for your application.

I happen to be a fan of Open Source and Free Software and I'm pleased to say that this book covers both MySQL and PostgreSQL. Naturally it provides the "big three" of Oracle, Microsoft SQL Server, and IBM's DB2.

This book really opened my eyes to possibilities in SQL that I really didn't know existed in spite of the fact that I have been using the language (apparently without mastering it) for almost two decades.
Read more ›
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

Customer Images

Most Recent Customer Reviews


What Other Items Do Customers Buy After Viewing This Item?