I'm a first-year digital development trainee studying for an exam on manipulating databases. I'm comfortable creating tables, adding columns, and inserting data, but I struggle much more with retrieving information—especially INNER JOINs, LEFT JOINs, subqueries, and understanding how tables relate to one another. I only have a few days before the exam, and I'll also need these database skills for an upcoming PHP course on dynamic websites. What's the best way to make SELECT queries and table relationships click quickly? I'd especially appreciate a practical progression of exercises from beginner to advanced, with explanations.
4 Answers
Don’t try to memorize isolated commands. For every query, first say what one output row should represent, then identify which table contains that information. After that, add the tables needed to connect the data, apply filters with WHERE, group only when necessary, and use ORDER BY at the end. Practice with a small schema such as Customers, Orders, and Products, gradually adding joins and conditions instead of jumping straight into complicated queries.
Use an interactive practice site or a sample database and work through exercises in stages: SELECT and WHERE first, then sorting and limiting results, then INNER JOIN, LEFT JOIN, aggregation with GROUP BY, and finally subqueries and common table expressions. A course focused on SQL fundamentals can help, but avoid having an AI write the answers for you. Ask it to explain an error or give you a similar exercise, then write the solution yourself. With only a few days left, focus on recognizing query patterns rather than advanced database internals.
A many-to-many relationship usually needs a linking table. For example, Puppies and Tricks can be connected through PuppyTricks, which stores PuppyID and TrickID. To list each puppy with its tricks, join Puppies to PuppyTricks and then join that to Tricks. If you want puppies that have no tricks as well, start with Puppies and use LEFT JOINs. Also learn the common relationship types—one-to-one, one-to-many, and many-to-many—and check the schema diagram before writing the query.
Try thinking about joins like lookups between spreadsheets. If one sheet contains users and another contains login records, the shared user ID tells SQL which rows belong together. An INNER JOIN returns only users with matching login records, while a LEFT JOIN starts with every user and adds login data where it exists—otherwise the login columns are NULL. Drawing the tables as boxes with primary-key and foreign-key lines can make the relationship much easier to see.

That way of breaking the query down makes sense. I understand basic queries now, but joins and subqueries still slow me down, so I’ll practice by describing the result before writing the SQL.