How to Learn SQL
Whether you’re interested in becoming a database developer, a data analyst, or just want to work with stored data in an application, having knowledge of databases is crucial.
Structured Query Language, or SQL, is an in-demand skill used in a variety of technical disciplines, from software engineering to data analysis, and allows developers to effectively and efficiently store data.
SQL powers many aspects of the technologies you use every day. When you sign up to a site like Amazon, your name and email will be stored in a database; when you add an item to your cloud to-do list app, it will be stored in a database. With this in mind, it’s clear that learning SQL can have a major impact on your career in technology.
This guide will discuss the best way to learn SQL online and give you a clear roadmap you can use to start your journey to mastering this exciting and powerful technology.
What Is SQL?
SQL is a technology used to create and manage databases. SQL works with a type of database called a “relational database”, which are structures of data that have both columns and rows. Each column in a table stores information about a category of data, such as a name or an email address, and each row stores values for a particular entry. So, one row in a database could store a single user’s name and their email address.
SQL offers a wide range of features that make it a useful language to learn. These include:
- Adding, updating, and deleting rows
- Creating tables to store information
- Modifying tables to change the structure of a database
- Retrieving rows from the database
- Filtering entries in the database
The SQL language has been around since the 1970s, and since then has become a standard database technology. This shows that, once you’ve learned SQL, you should be able to use your skills for some time in the future.
Why Should You Learn SQL?
SQL is a programming language not just for programmers, but for anyone who works with large sets of data, or who wants to store data in a specific way. This is the case both because SQL provides a number of useful functions that can apply to many different problems and because SQL has a simple syntax.
One of the top reasons for learning SQL is that the language is simple, yet powerful. In fact, you don’t even need any programming experience to get started with SQL.
Once you’ve mastered SQL, you’ll have a whole new set of skills around storing and querying data which could be helpful in a number of ways in your life and career. You could use SQL to help you take on new data-related projects at work, or you could use SQL to create a database for your own personal website. Now, let’s delve into how to learn the basics of SQL fast.
How to Learn SQL Fast
So far, we’ve discussed the basics of SQL and why you should learn the language, even if you are not a programmer. But the next question we need to ask is: how do you learn SQL?
Let’s walk through a few steps you should follow when starting to learn SQL, to make sure you make the most of your learning time.
Step 1: Start with the Fundamentals
While you may have big ideas about how you can use SQL, you need to start small and master the fundamentals first. Luckily, because SQL is so widely used, there is no shortage of resources you can use to learn the basics of the programming language.
Your first step should be to explore the syntax of SQL and its queries and commands. Then, once you feel comfortable with those topics, you’ll be ready to start investigating more complex usages of SQL. Here are the main topics you should explore as you start your learning journey:
The term “manipulating data” may sound confusing, but in simple terms, it means learning how to add, change, and remove data in a database.
The first step to mastering SQL is learning how to write an SQL statement, which is a command sent to the database that instructs it to perform a certain action. Once you know how to write a statement, you can start learning about commands used to create databases, update databases, and delete the contents of a database.
Here are the main topics and keywords you should learn:
SQL allows you to write queries that filter out data based on a set of conditions. For instance, you may only want to search for email addresses that begin with “s” in a database. As you learn the basics of writing a statement and manipulating data, you should explore how to write queries using the query keywords offered by SQL.
Here are some of the topics you should explore:
- SELECT statements
- WHERE statements
- The AS, DISTINCT, and LIKE statements
- BETWEEN statement
- ORDER BY and LIMIT statements
As we discussed earlier, SQL is often used for data analysis. As a result, SQL offers a number of different functions that allow you to perform mathematical operations on the data in a database. These functions, which allow you to retrieve insights based on the data stored in a database, are called “aggregate functions.”
Here are the main topics you should learn when exploring aggregate functions:
In SQL, it is possible to work with multiple different tables at the same time and run queries that reference those different tables. In fact, this is an important part of maintaining a well-structured database. That’s where connecting tables come in. Connecting tables allow you to work with multiple sources of data contained within different tables.
Here are the main topics you should learn about when you’re ready to explore connecting tables:
- Why you should connect tables
- INNER, LEFT, and CROSS JOINs across multiple tables
- UNION statement
- WITH statement
- Primary keys and foreign keys
Where to Learn About SQL
In the last section, we outlined the basic topics that you should explore when you’re starting your journey to learning SQL. The next question you’ll have is: where can I learn about SQL?
There is no “right way” to learn about SQL, and every learner has their own styles—some prefer reading articles, whereas others prefer online videos. But no matter what your style is, you should have no trouble finding free SQL learning resources to help you pick up the language at zero cost. To help you get started, here are a few online resources that are great for SQL beginners:
- Career Karma’s Introduction to SQL series
- Learn SQL by Codecademy
- edX SQL courses
- Intro to SQL: Querying and Managing Data by Khan Academy
- The Manga Guide to Databases
- SQL Cookbook by O’Reilly
- Intro to Relational Databases by Udacity
- Interactive tutorials on SQLBolt
These resources cover all the basic topics you need to know when learning SQL. Then, once you’re ready, you can take the next step on your journey: work on a project.
Step 2: Work on an SQL Project
There is no better way to practice your SQL skills than to work on a real-world project. This allows you to put your theory into practice, and work on projects that interest you, instead of projects that are listed in an online course or tutorial.
Once you’ve mastered the fundamentals, you should start to think about an idea that you want to bring to fruition that requires SQL. For example, you may want to build a database for your blog, or you may want to analyze an interesting dataset you found online. Whatever you choose to do, make sure it is something you are interested in—the more invested you are in the project, the more likely you are to complete it in the end.
Are you looking for ideas to help you get started? Here are a few that you could explore:
- Inventory control management system
- Restaurant order management system
- Employee records storage system
- Airline reservations system
- Online shopping cart
In addition, instead of building your own database, you could use tools like Kaggle to find a dataset, then use SQL to analyze that dataset. For instance, you could use Kaggle to find a dataset on avocado prices, then you could create a database using that information and analyze it using the queries you have learned.
The only limit to the project you decide to pursue is your own imagination. Of course, you should start small, to make sure that you do not take on too many tasks at once. But as you start to feel more comfortable with the language, you can scale up your projects to use more queries and more complex SQL commands.
Step 3: Document Your Learning
It can be tempting to write an elaborate SQL query, download its results, and call it a day. After all, once you’ve written a query, you’ll have already generated the data you need.
This approach skips one key part of the development process: documentation. Writing documentation allows you to analyze your findings, test your results, and also validate whether or not the outcome of a query or project was what you expected.
When you’re getting started, your documentation can be as simple as taking notes throughout your development process. Ask yourself questions like: “Why did I write this query using these statements?” and “Is there a more efficient way to accomplish this task?” In doing so, you’ll be able to flex your learning muscles, and keep track of why you have made certain decisions.
Writing documentation can also help you reflect on your project. After you’ve written a query, you can go back and read the documentation you have written, which will help you better understand why you approached a problem in a certain way, and whether the result of your project is in fact what you were looking to create.
Step 4: Write Reports
Writing reports is a more intensive way of documenting your work, but it is an important part of working with SQL. Once you’ve written a query and taken notes, then you’ll have everything you need to write an insightful report on your findings.
Reports serve a couple of purposes. In a professional development environment, managers and data analysts usually prefer to work with reports once a dataset has been analyzed. This is because reports are written in a way that allows anyone to understand their contents who has the relevant background knowledge—you don’t usually need to have SQL experience to read a report.
Businesses rely on reports from their engineers and data analysts to make decisions. And that’s not all—writing reports can help you refine your thinking about a particular problem, and in the process, identify opportunities to improve your work.
Step 5: Find Uses of SQL at Work
One of the great parts about learning SQL is that the language is so flexible that you can usually find some way to apply it to your existing work. Using SQL at work is not something that will happen instantly. You’ll need to put some thought into what you want to accomplish, and you may need to convince your boss that using SQL will help you be more productive.
If possible, you could ask to analyze a dataset with which you are working using SQL. Then, you could present your findings in a short report to your boss. Or, if you are already a developer, you could ask to do some work with the data analysis team to help expand your repertoire of skills.
Given how useful SQL can be in storing and analyzing data, you should have no trouble coming up with ways that it could overlap with your work. And even if you can’t use SQL at work, you can still spend time learning about who uses the technology and try to work closely with them so that you can refine your skills in a real-world environment.
Step 6: Share Your Work
Documenting your work comes with one added benefit we have not yet discussed: once you have a report or some notes, you can start to seek feedback from other people.
There are a couple of ways you can share your work when you’re learning SQL. If you are using SQL on the job, you may want to seek feedback on your work from co-workers. Or if you are working on a few personal projects, you may want to write a series of blog posts to hold yourself accountable and to share your findings from a project with the world.
Blogs are a great way to share your work because anyone can read them at any time. People who are just starting to learn SQL could come across your post and use it to help themselves learn. Or an SQL expert could land on your page because they are stuck with a problem, then reach out with a few comments on how to improve your work.
In addition, one of the people who read your blog may even be a recruiter or a hiring manager, which could help you break into a career in tech if you’re not already in a technical position.
If you’re not ready to start a blog, you could also share your queries and projects in a community such as Dev.to, or an SQL-specific community. Joining communities will both allow you to access a group of people with whom you can share your work, and will help you learn from other developers who have been in your shoes before.
Learning SQL can be time-consuming, but it is a worthy investment. Whether you are a marketing manager who is looking to explore new ways to analyze the data you have, or someone looking to explore new ways to store data, SQL is a great skill to learn.
Earlier in this guide, we mentioned how SQL has become a crucial technology for data analysis, even among people who don’t know how to code. This is worth repeating because, unlike many other programming languages, there are very few technical barriers to entry. If you are ready to commit to learning SQL, you’ll have no trouble getting started.
The first step on your journey should be to master the basics—statements, writing queries, manipulating data, and so on. Then, you can progress on to building projects, writing reports, and even trying your hand with some SQL at work (if possible). As you proceed through your learning journey, you can start to take on more complex projects, and learn how to fine-tune your queries.
Understanding how to use SQL is a valuable skill in the data-driven world in which we exist today, and once you’ve learned it, you’ll have a new tool you can use to work with data for the rest of your career.