SQL Quick Reference PDF: Free Printable MySQL and SQL Server Cheat Sheet

You already write SQL. You don’t need another tutorial on what a JOIN is; you need the syntax you forgot, the MySQL vs SQL Server difference that broke your query, and a reminder of the trap you fell into last month. That’s what this Quick Reference is for.

Cover of Simplify SQL: Quick Reference
  • Free PDF, A4, made to print
  • 20 SQL topics, one page each: what it covers, the syntax, and the traps
  • MySQL and SQL Server side by side on every page
  • A complete 6-page cheat sheet and the 12 traps that cause wrong results

It’s the short version of my book, Simplify SQL for Absolute Beginners: one A4 page per topic, with the syntax in a table and the mistakes that cause wrong results. Print it, keep it next to your keyboard, and stop searching for the same five things every week.

Download it free

Get the free Quick Reference (PDF)

Enter your email and the download button appears right here. You’ll also get one short email when a new tutorial goes live. No spam; unsubscribe any time.

Thank you! Your download:

Print it double-sided: every topic fits on one page. On US Letter paper, choose “Fit to page” in the print dialog. The examples use ShopDB, the free practice database.

We only use your email to send SimplifyDatabase updates. See our Privacy Policy.

Who it’s for

  • Developers who move between MySQL and SQL Server and keep mixing up LIMIT and TOP, LOCATE and CHARINDEX, or the argument order of DATEDIFF.
  • Analysts who write reports and want the window function, CTE and GROUP BY patterns on one page.
  • Students revising for an exam or a first SQL interview.
  • Beginners who finished a course and want a summary to revise from. (If you’re just starting, the free book is the better place to begin.)

What’s inside

20 topics, one page each. Every page has three parts: Covers (what the topic is about), Key points (the syntax you need, in a table) and Watch out (the mistakes I see most often, in real projects and from beginners alike). The topic numbers match the chapters of the full book:

  1. SELECT, WHERE, ORDER BY and LIMIT
  2. DISTINCT and aliases
  3. LIKE, IN and BETWEEN
  4. Working with NULL
  5. The CASE expression
  6. GROUP BY and aggregate functions
  7. HAVING vs WHERE
  8. Primary keys and foreign keys
  9. JOINs
  10. SELF JOIN
  11. UNION and UNION ALL
  12. Subqueries and CTEs
  13. Data types
  14. Constraints
  15. INSERT, UPDATE and DELETE
  16. Transactions
  17. Normalization (1NF, 2NF, 3NF)
  18. String functions
  19. Date functions
  20. Window functions

The cheat sheet (6 pages). Every task from the book with MySQL and SQL Server side by side: reading and filtering, NULL, CASE, grouping, joins, UNION, CTEs, window functions, text, dates, types and constraints, and changing data.

ShopDB at a glance. A one-page map of the six tables every example uses, so the examples make sense even if you’ve never seen the database.

A sample page: JOINs

Here’s one topic page exactly as it appears in the PDF (as text, so you can copy from it):

Chapter 11 · JOINs

Covers:

  • Put matching rows from two tables side by side with INNER JOIN
  • Keep every row from one table with LEFT JOIN, and find what’s missing
  • Know what RIGHT JOIN and FULL JOIN do (and why you rarely need them)
  • Join three or four tables in one query
  • Combine JOIN with GROUP BY, and avoid the LEFT JOIN trap that catches everyone

Key points

You want Use
Only rows that match in both tables INNER JOIN (or just JOIN)
Every row from the first table, matched or not LEFT JOIN
Rows in A with no match in B LEFT JOIN + WHERE b.key IS NULL
Every row from both tables FULL JOIN (SQL Server; not in MySQL)
Data from three tables One extra JOIN … ON per table
A filter on the right table that keeps all left rows Put it in ON, not WHERE
A count that shows 0 for no matches LEFT JOIN + COUNT(right_table.key)

For most everyday work you’ll only need INNER JOIN and LEFT JOIN. Get comfortable with those two first.

Watch out

  • A condition on the right table in WHERE turns a LEFT JOIN into an INNER JOIN. Put it in ON.
  • Joining on the wrong column runs without error and returns nonsense. Join a foreign key to the key it points to.
  • Two tables with the same column name: write p.CategoryID, or you get “ambiguous column”.
  • Joining two lists (orders and payments) multiplies the rows, so totals are too big. Total each list first.
  • DISTINCT hides duplicate rows from a bad join; fix the join instead.

The 12 SQL traps worth remembering

The last page of the cheat sheet lists the traps that produce wrong results without any error message. Here they are, with the chapter of the book that explains each one:

  1. = NULL is never true. Use IS NULL. (6)
  2. NOT IN (... NULL ...) returns nothing. Use NOT EXISTS. (5, 14)
  3. A condition on the right table in WHERE turns a LEFT JOIN into an INNER JOIN. Put it in ON. (11)
  4. Joining two lists multiplies the rows, and every SUM is wrong. Total each list first. (11, 14)
  5. UNION silently drops rows that look the same. Use UNION ALL for totals. (13)
  6. SQL Server: whole number ÷ whole number drops the decimals (7 / 2 = 3). (8, 15)
  7. MySQL: CONCAT with one NULL gives NULL. Use CONCAT_WS. (20)
  8. BETWEEN on a date-and-time column misses the last day. Use >= start AND < next day. (21)
  9. A function on a column in WHERE stops the index being used. Compare the bare column. (20, 21)
  10. ROW_NUMBER and LIMIT with ties give a random order. Add a tie-breaker column. (3, 22)
  11. UPDATE or DELETE without WHERE changes every row. SELECT first; use a transaction. (17, 18)
  12. A failed statement doesn’t end the transaction. ROLLBACK, don’t COMMIT. (18)

Every one of these is explained in detail on this site too: start with NULL in SQL, SQL JOINs and UNION vs UNION ALL.

Frequently asked questions

Is it really free?

Yes. Enter your email and the download appears straight away. You’ll get the occasional email when a new tutorial or chapter is ready, and you can unsubscribe at any time.

Does it cover MySQL or SQL Server?

Both. Where the two databases agree, there’s one line; where they differ, both are shown side by side. Almost everything also works on MariaDB.

How is it different from the free book?

The free book teaches SQL from zero, with every query explained and practice questions. The Quick Reference is the summary for when you already know the ideas and just need the syntax and the traps. If you’ve signed up for one, the other’s download appears without signing up again.

Can I print it on US Letter paper?

Yes. It’s laid out on A4; choose “Fit to page” (or “Shrink to fit”) in the print dialog and it prints fine on Letter.

Related articles

Scroll to Top