With all of the resources available, learning SQL the “right way” can be difficult. Finding the best way to learn SQL is tricky because everyone learns things differently. But, after training tens of thousands of students — seeing what works and what doesn’t — we’ve come up with a few easy steps that anyone can follow. Here’s the best way to learn SQL:
Step 1: Determine why you want to learn SQL
Before you dive into a SQL course, it’s important to be sure you have a good answer for the question “why should I learn SQL?”
That’s because while SQL isn’t too difficult to learn, no learning journey is ever totally smooth sailing. You will likely face moments of frustration and confusion. If you don’t have a good reason to learn SQL, it’s going to be very easy for you to quit in those moments.
There’s no one answer to that question, but here are some of the most common reasons people want to learn SQL:
- You’re feeling bottlenecked by Excel and sick of VLOOKUP
- You want to be able to access your company’s data easily, on-demand
- You want to be able to work with bigger datasets quickly
- You want to get a job as a data analyst, data scientist, or data engineer (and you know that SQL is the single most important skill for those jobs)
- You want to create transparent, repeatable data processes to reduce repetitive tasks
Of course, those are just a few broad reasons. You need to find a reason that speaks to you. It may be something very specific, like a particular question you’d like to answer about your customers, or a particular dashboard you’d like to build.
(Can you build a dashboard with SQL? Sort of. We’ll get to that later!)
Step 2: Learn the basic syntax
This typically isn’t people’s favorite part of learning a programming language (or in this case, a query language). But it can’t be avoided. There’s just no way you can get to a functional level of SQL without being able to look at something like this and know what’s going on:
Thankfully, learning this may be easier than you think. While that probably looks complicated and confusing at first glance, SQL’s syntax is actually pretty straightforward. And the list of SQL commands — the all-caps words like
SELECT in the code above — that you’ll actually use on a regular basis is short.
The key to being successful with this step is to power through it as quickly as you can. Set aside a few hours to work through Dataquest’s first SQL course all at once. Or pick another learning resource and set aside enough time to get through the basics.
What’s most important here is that you don’t drag this out. You want to get to the point of being able to actually do things with SQL as quickly as possible, because being able to dig into real problems and find the answers is a powerful motivator. That’s what’s really going to keep you motivated and learning, so we want to get you to that point as fast as possible.
Step 3: Start working on guided projects
As soon as you’ve learned the basics, it’s time to start diving into actual projects using SQL.
If you’re learning with us at Dataquest, this is built into the curriculum, with interactive guided projects that challenge you to use your new SQL skills to query and analyze real databases for answers.
If you’re not learning with Dataquest, we suggest the next best thing: guided projects and tutorials.
You need to find something that will give you a bit of structure and guidance, because at this stage, the process of trying to build a full SQL project from scratch would probably be frustrating. You want something that you can try to do on your own, but that also offers some guidance you can look to when you get lost or aren’t sure what to do next.
For example, here’s a tutorial on joins in SQL. This would be great practice, but try to work through it on your own, checking the code snippets only to make sure you’re right after you’ve written your own queries.
Remember, the goal here is to work on guided projects with increasing independence. If you’re simply copy-pasting code from a tutorial, you won’t be learning much, so be sure you’ve given it your best effort before you check the answer.
Step 4: Familiarize yourself with helpful SQL resources
Once you’ve worked through some guided projects, it’s time to step out on your own. The good news: you can work with exactly the data you want, to answer exactly the questions you want. How motivating!
The bad news: there’s no answer key you can check! So before you start your first project, it’s helpful to bookmark a few useful SQL resources. Remember, there’s no shame whatsoever in Googling for answers — even the most seasoned SQL developers and users do this frequently!
Useful SQL resources:
- Learning SQL 2nd Edition (PDF) — This O’Reilly book on the basics of SQL is available for free in PDF format, and makes a good reference.
- StackOverflow SQL questions — Chances are, any SQL question you’ll have has already been answered here. But if it hasn’t create an account and ask it for yourself!
- Github — If SQL is your first foray into the world of programming, you may not have an account here. If that’s the case, set one up and start learning how to use it! Github is great for sharing your own SQL projects with the world (and potential employers), and it’s also an amazing resource for looking at other people’s code.
- /r/SQL — Reddit has a SQL community that’s large, active, and (mostly) happy to answer questions.
- The Dataquest community — Our community is active, friendly, and ready to help you with all your SQL questions. Best of all, it’s open to everyone — you don’t have to be a Dataquest subscriber to get help there.
Step 5: Build your own SQL projects
Now that you know some good places to look for help when you get stuck, it’s time to start working on your own SQL projects.
This is where the answer you came up with in Step 1 really starts to matter. Knowing why you want to learn SQL will probably help you answer the question: what projects should I work on?
The short answer? Work on projects you care about. If you’re learning SQL because you’re sick of Excel slowing you down at work, then your first project should probably be figuring out how to do those work tasks more efficiently with SQL.
If you’re learning SQL because you want a particular job, you should work on SQL projects that are as close as possible to what you’ll actually be doing when you get the job. For example, if your passion is crunching data to help decrease carbon emissions and make things more energy-efficient, then you’ll probably want to work on projects that relate to that goal.
We should note: this step can be a little challenging if you’re not working at a company, or if you don’t want to use company data for your projects. Finding a SQL database that’s freely available to all that contains exactly the kind of data you want to work with can be difficult, depending on your goals.
But never fear! While it takes a little bit of extra effort, it is possible to convert any downloadable data you find in CSV format (or something similar) into a SQL database format such as a SQLite table. There are even sites that can make the conversion process pretty easy.
Whatever data you want to work with, with a little digging, you should be able to find a way to work with it using SQL.
And don’t forget: share your SQL projects on your Github when you’re finished with them. Go back and update them when you learn something new!
Step 6: Make more advanced projects
The final step is essentially a continuation of Step 5, and you can repeat this for as long as you’d like. The key to continued learning here is that you have to ramp up the challenge.
Once you’ve learned how to build the SQL project that initially motivated you — maybe you’ve written a query that replaces your old Excel workflow — it can be tempting to keep doing projects along those same lines.
Doing the same thing over and over is good for retention, but it’ll stunt your growth. It’s best to try to ensure that with each new project, you’re learning or trying at least one new thing — something you don’t already know how to do.
This could mean you’re taking on an entirely new project, or it could mean revisiting an old project to give it new complexity.
It could also mean taking on challenges you may not have thought about previously, such as:
- Can you integrate your SQL skills with a tool like Mode to produce a dashboard?
- Can you teach someone else how to query your company database using SQL?
At this point, you’ll havr the skills to do more or less anything you want with SQL — not because you know how to do everything, but because your project-building process has taught you how to find the answers to anything you don’t know.
Frequently-asked questions about SQL:
Is SQL difficult to learn?
That’s a very personal question — what’s very easy to one person may seem very difficult to the next, and vice versa. However, most people find SQL pretty easy to learn, especially when compared to full-on programming languages like Python or R.
That’s because unlike a “full” programming language, SQL is a query language. It’s built specifically for interacting with relational database management systems such as Microsoft SQL Server, Oracle, SQLite, MySQL, etc. For that reason, there’s not as much to learn, and some of the more complex concepts that exist by necessity in more holistic programming languages aren’t a factor in SQL.
That said, the fact that most people find SQL relatively easy to learn does not mean that you will, or that you should feel ashamed if you find it challenging! Particularly if this is your first foray into the world of programming, you should be ready for a challenge.
(But don’t worry. No matter what your background is, you can totally learn SQL. Our community is here to help you anytime you need it!)
SQL or Python: which is better to learn?
The answer to this question really depends on your goals. They’re very different things.
SQL is a query language. It’s really only useful for interacting with, filtering, and lightly analyzing data from databases. It offers a lot of power for working with data in those contexts, but it can’t do all the things a full programming language like Python can do.
Python is a programming language. That makes it a bit more complex to learn, but it also means it can do a lot more. You can analyze data in Python, but you can also use it to build machine learning models. Or make video games. Or program a robot. Or design art.
If you work with data often — if you’re opening spreadsheets every day and you know what VLOOKUP is — there’s a good chance you’d benefit from learning both languages.
At Dataquest, we teach both Python and SQL as part of our Data Analyst and Data Scientist career paths. Both skills are required for full-time data jobs (although R can be substituted for Python, learning SQL is non-negotiable).
Can you learn SQL on your own?
Yes. We’ve seen thousands of students do exactly that, working through our interactive SQL courses on their own time, at their own pace.
Even if you’re not using Dataquest, it is absolutely possible to learn SQL on your own. Having a supportive community you can turn to for help certainly can make things easier, though!
How fast can you learn SQL?
The short answer is: pretty fast.
The longer answer is you can learn the basics — enough to be functional — quite quickly. Even with part-time study (for example, working on SQL in the evenings after a full-time job), many learners who’ve never coded before can reach their goals and be able to complete independent SQL projects in just a few months.
If you have some programming experience and/or you’re willing to spend a bit more time each day studying, you can learn enough SQL to accomplish your goals even faster than that!
But with that said, learning SQL is like learning any language — there’s never really an end point. Even the pros who are using SQL at work every day still learn new things now and then. Learning any programming language should be considered a lifelong journey, not something that starts and ends over the span of a few months.