MySQL

What’s the best book for learning MySQL from the ground up. I have programming experience, but only a little experience with databases.

I’m trying to learn SQL myself. I started with SQL for dummies and it was alright - it provided a general background. I’ve moved on to Joes2Pros, which seems more in depth.

Also, I’m finding certain websites very helpful:
SQL Tutorial

I’ve been referenced here for specific problems, I’m undecided on it.

It depends on what you want to do. If you’re primarily going to be writing queries - that is, reading from pre-existing databases, any Dummies-type SQL book should work for you, as long as it covers MySQL’s idiosyncrasies.

If you’re looking to get in to administration and the guts of the daemon, look at O’Reilly’s High Performance MySQL.

If you plan on designing databases for typical applications - that is, non-Data Warehouse stuff - it’s a really, really good idea to take a primer on relational modeling. This book will melt your brain, but it’s worth it.

Teach Yourself SQL in 21 Days is a staple reference work around here.
I bought it and use it occasionally.

I actually stumbled across an on-line tutorial site that gave me more ‘hands on’ learning shortly after I bought the book. It’s not the one linked below by Meatros, but I can’t remember which one it is now. I seem to have lost the bookmark that was on my browser at home…

Nevertheless, it’s a very useful tome to go back to when you’re hunting for just the right syntax or obscure command.

—G!

It depends on if you want to design databases or just write queries to existing ones.

For designing, the book “Database Design for Mere Mortals” is what made things finally click for me (that and lots of experience over time)

SQL queries are a fair bit easier I think than database design. It looks like there is an SQL Queries for Mere Mortals too but I haven’t read it.

I second both these suggestions.

I’d suggest really focusing on learning general SQL first. People unfamiliar with SQL might not entirely realize it, but there is an ANSI SQL standard that almost all modern RDBMS will execute perfectly fine.

Oracle, DB2, MySQL, and Microsoft SQL Server will all pretty much run standard ANSI SQL. Now, each of those vendors has functionality built in above and beyond standard SQL, if you get used to using one vendor’s product you may get used to the features in their version of SQL that don’t exist in a competitor’s product and get confused.

But if you learn the general rules of SQL first (which are generally applicable in all major RDBMS), you can pick up a lot of the vendor specific stuff as needed. If you’re planning on being an Oracle or DB2 DBA or something you’ll need a lot more specialized knowledge on those vendors, of course.

The big things I’ve seen that are vendor specific are things like data types, built in reserved keywords, and certain other features. Certain data types are typical of any RDBMS, but others are more specialized to the vendor (and some of these may share the same name, for example a DB2 TIMESTAMP field is different than an Oracle TIMESTAMP field.)

For whatever reason PL/SQL, DB2 SQL, and T-SQL all use different syntax for limiting the results of a query for example.

If you only want to return the first ten rows that match your criteria in T-SQL, you use the “SELECT TOP 10” command. In PL/SQL, in your where clause you’ll have the “and ROWNUM < 11” criteria, and in DB2 at the end of the statement you have “FETCH FIRST 10 ROWS ONLY.”