views:

143

answers:

6

Hi,

I had a big interview that I screwed up when the interviewer asked me to join three tables. I can verbally describe the different types of joins, but I froze up. I'm looking for something that gets me used to these types of problems so I can anticipate how to solve them. Anybody have any SQL excercises they could possibly recommend?

+5  A: 

I'll start with a couple:

Jeff's A Visual Explanation of SQL Joins
SQL JOIN - SQL Tutorial
Understanding SQL Joins

o.k.w
+1 for Jeff's Visualization of SQL Joins - excellent stuff
marc_s
Yeah, it's on page one of the google search for "sql joins" :P
o.k.w
+1  A: 

I would install MySQL or any other free SQL database, and just go through some examples. Best way to remember things is by having done them with repetition. Also, seeing actual data results always helps to visualize what the different functions do. I know MySQL offers lots of webinars, that might be a good place to start?

MySQL Webinars

jaywon
+1  A: 

The w3schools website (a site mainly about web stuff) has a good primer on SQL including joins Sql Tutorial. The best bit of the tutorial is the online Sql terminal with a sample schema that makes it easy to practice what you have learned: try it practice makes perfect!

Tendayi Mawushe
+1  A: 

SQL: Joins

At the same time you can participate in SQL puzzles for enhancing ur skills

priyanka.sarkar
A: 

thanks, I found sqlzoo a good resource, as well as the ones you mentioned

Jeff
A: 

You might try to create a database with three tables, such that you would need to take joins on all of them to get used to multiple joins. One example:

User(user_id, name,email) has_many Cars(car_id, car_name, car_model_id), and Car has_one Model(model_name, model_id, year_of_model) etc, and then try to answer a few questions like:

  • how many cars does a user A have, and what are their models
  • how many distinct models of cars does a user A have

etc etc. Such small exercises can help you get started, so that you can think comfortably about models, joins, and relattions etc. (The example is probably not complete as I havent specified the other direction of the relation, but you can do that yourself. for example, a user has_many cars, and a car has_one user, and a car has_one model and a model has_many cars.)