Back to articles list Articles Cookbook
10 minutes read

How to Learn SQL: 6 Ideas for Newbies

Learning a new skill can be a daunting task, especially in programming. SQL is not immune to this. Luckily, with the Internet and the explosion of programming-related information out there, there are a lot of options you can use to undergo your SQL training!

But we then come to a new roadblock. Where to begin? How will we know which option is best for our budget, skill level, and schedule? This article tackles these questions and gives you a roadmap – or should we say a couple of them – of your journey, so scroll down to find out how to learn SQL!

A Brief History of SQL

Let’s start by reviewing some basics about the language. SQL stands for standard query language. It is used for managing data in relational databases. SQL was initially developed by IBM and Relational Software, Inc. (now Oracle) in the early 1970s. The language evolved and acquired greater commercial success in the 1980s. Finally, it became an ANSI standard in 1986 and an ISO standard in 1987. Since then, the SQL standard has evolved to include an increasing number of features.

It’s important to know that SQL is usually not portable across different database systems unless you adjust it; each environment has its own ‘dialect’ of SQL that may not be understood by others. So if you write something for DB2, don’t be surprised if it does not work in Oracle or Microsoft SQL Server. The ‘odd man out’ in this picture is PostgreSQL, which strives for compliance with the SQL standard.

How to Start Learning SQL

Now let’s dig into what’s available to help beginners with their SQL training.. There are at least six ways a perspective learner can start or continue their SQL journey. We’ll compare paths using these metrics:

  • Price: From free to expensive (How much do I have to pay?)
  • Level: From novice to expert (What prior knowledge do I need?)
  • Setup: From simple to complex (What do I need to start learning? Can I start now?)

Interactive Online SQL Courses

If you wonder how to learn SQL, you should start with taking a look at interactive online courses. They are a fast and cheap way to start SQL, and there’s no need to install anything on your local workstation. This is great when you need to get a quick start in the language; for example, I’d recommend them to businesspeople, students, and web developers who don’t need to delve into database workings right now. (Of course, you can always go deeper later!)

There are many websites that teach several programming languages, including:

Some of these sites have SQL components. However, most multi-purpose interactive sites focus on popular computer programming languages (Java, Ruby, Python); SQL feels almost like an afterthought or as a specialized part of some web stack. It’s not a subject unto itself.

So for this path, the best way to learn SQL is finding a site dedicated to this language, like These sites give step-by-step instructions on writing SQL queries for all experience levels. And all of the steps are interactive. They slowly build you up to the point where you can confidently work with data. They often feature sections with guides for beginners explaining how to learn SQL most efficiently.

To summarize this path’s metrics:


Comprehensive Online SQL Courses

Some people love to learn by doing and can’t wait to get their hands dirty; others begin with a theoretical overview of their subject. There is nothing wrong with either approach. Similarly, there’s no one best way to learn SQL. In fact, it’s well known that there are different learning styles and theory-first is one of them.

If you like to geek out, comprehensive courses are for you. Fortunately, there are lots of online courses that suit a theory-first style. They range in price from free to, well, not so free.

Let’s look at some good places to start:
Stanford Online : Databases
Udacity : Intro to Relational Databases
Safari : Learning Path: SQL and Relational Databases

Stanford offers a free course on various database topics. Overall, it’s a bit academic and includes related subjects, like database modeling. It gives some clues on how to learn SQL, but treats this language as part of a larger picture. There aren’t many exercises, and the course does not cover the complete SQL language. There is some interactivity, so you do not need to set up your own environment.

Udacity also offers a free course on relational databases. The estimated duration is four weeks, and it is mostly targeted at users of higher-level programming languages who need basic SQL. You need to setup your own database and environment.

In my opinion, Safari’s offering is the hands-down winner in this category. It’s not free, as the course itself is part of Safari’s online book platform. However, it’s detailed and goes through the complete relational theory, which is the basis for SQL training. The downside is that it isn’t interactive and you have to set up your own environment.

To summarize this path’s metrics:


Competitive Programming Sites

Competitive programming sites – a.k.a. hackathon sites – are a surprising place to brush up SQL knowledge. What is a competitive programming site? It’s a place where programmers or teams of programmers compete among themselves to solve a certain program problem the fastest (or solve the most problems, or be the most accurate, etc). Most of these sites have a “warm up” area to let coders do a bit of SQL training before they join the fray.

One of the most popular sites where you can dabble in SQL is HackerRank. HackerRank has a list of domains where you can practice solving problems in a myriad of programming languages. One of these domains is SQL. (They also have a general database domain.)

In these sites, you can interactively practice solving some real problems in SQL, but you will get no guidance on how to write code correctly. If you wonder how to learn SQL on your own without additional help, it may not be the best solution: you only get the problem and the opportunity to see if you solved it. You can even challenge your friends to solve the problem. While this competition-based training can be fun, it is more suited to seasoned SQL coders.

To summarize this path’s metrics:


Local SQL Classes

The traditional way of learning SQL and database-related subjects is in the classroom. This is the type of learning we did for years in school. It is your plain-vanilla “teacher in front of a class, showing and explaining” routine. Some people find it the best way to learn SQL as it has a more human touch. But others find it outdated and impractical. The downsides include finding a course in your area, enrolling, coming to class at a predefined time, and the fact that courses can be expensive.

I have no recommendations in this area, since it is very individual and depends on your location. There are a lot of downsides to this approach and I would not recommend it. If you like a more personal approach to teaching, a better alternative is hiring a tutor over Skype to guide you through the SQL language. There are also plenty of freelancing sites where tutors can be found.

To summarize this path’s metrics:


Learning SQL by Book

Somebody once told me no wise person exists who does not read books. As I get older, I see the truth in those words. Books about technical subjects, including SQL, can be a huge source of knowledge, so if you want to know how to learn SQL on your own, try this path. But as the subject is broad, there are many books to choose from. This in itself can be overwhelming. Let’s look at some examples of popular SQL books you can find online or in your local bookstore:

Joe Celko’s books are considered classics in the SQL programming world. They’ve stood the test of time quite nicely. The author served on ANSI and ISO SQL Standards Committees and contributed to various SQL standards. His topics appeal to a more professional audience looking for advanced SQL training, with books covering various facets like the representation of hierarchies.

O’Reilly has plenty of books covering SQL. I personally would recommend their SQL Cookbook, which are also geared for the advance end of the spectrum.

The Manga Guide to Databases is basically a comic about databases. It’s fun and simple but it won’t help you if you want to know how to learn SQL on your own because it doesn’t give pure SQL a lot of space. The series has a myriad of books on SQL that cover simple to complex topics.

Other than books, check out various tutorials and blogs related to SQL (like Vertabelo Blog | Data Modeling & Web Development). These are another good place to start, although they will take more of your time. It takes time to set up the environment, to start coding, and to practice. (This is the same as with the local class approach.)

You could always download an image of a system with a pre-installed database and use this to practice quizzes and examples. But this would be tedious and time-consuming. And if you don’t know what an image is, then you would have to invest even more of your time to figure it out. Interactive online courses do the setup for you.

Another setup alternative is a fiddle. Fiddles are basically virtual environments that you can use to test code. SQL Fiddle is available online, and it lets you practice SQL without setting up your own local environment. However, it supplies no guidance, and fiddles are notoriously unstable. I would recommend this option for quick tests only.

To summarize this path’s metrics:


Hands-On Projects

Nothing beats working on something you dreamt up yourself. This way of learning is a combination of different styles. It’s also a great way to motivate yourself to get coding. But if you don’t know where or how to begin, it’s pretty difficult to start. I would use this method if I needed additional, advanced SQL training to deepen my knowledge on any programming subject (be it a language or a concept) rather than learning from scratch. The time spent in finding and going through various tutorials could be used more effectively in a well-structured online course. Don’t fall for the trap of thinking that this is wasted time, though. What you spend at the beginning of your SQL training will be repaid tenfold later on.

You will also have to invest a lot of time in setting up your environment. Here no fiddle can help. It’s your project, your baby, and your environment.

To summarize this path’s metrics:


Making the Comparison

Let’s examine all of our choices side by side:

Interactive web PRICE LOW
Interactive web LEVEL LOW
Interactive web SETUP LOW
Online course PRICE MEDIUM
Online course LEVEL HIGH
Online course SETUP LOW
Competitive web PRICE LOW
Competitive web LEVEL HIGH
Competitive web SETUP LOW
Local class PRICE HIGH
Local class LEVEL MEDIUM
Local class SETUP MEDIUM

Still Wonder How to Learn SQL?

How to learn SQL is a very individual issue. It depends on your current level of knowledge and what made you learn the language in the first place.

You know how to write queries and need more advanced SQL training without spending too much? Get some books.

You need to prep for a test? Go for a comprehensive online SQL course.

You’re a true beginner? Nothing beats a structured interactive online SQL course.

Whatever you choose, the main thing is to get going and give it a try. If one path doesn’t work, try another. Don’t give up, and you’ll be rewarded by understanding how to use SQL.