How to Learn SQL
Structured Query Language (SQL) is used to query databases and is considered one of the easiest languages to learn. If that’s not good enough news, consider this: if you’re familiar with Excel, you are pretty much familiar with some of the overarching concepts of SQL.
The first thing you would want to do is download MySQL, a free database compatible with most operating systems. MySQL is a server where you can create databases and query them using SQL. You can get started looking at data tables right away in your terminal (after following the instructions and logging into MySQL with your password) because there are some practice databases included, or you can create your own.
- To create your own database called “cars”, you can type CREATE DATABASE cars in your terminal.
- Next, type USE cars to go into that database
- Now you can create tables, each with its own set of data, that are related to your database!
We will further explore some of the topics needed to gain an understanding of SQL as well as resources to help you on your SQL learning journey.
What You Need to Know About SQL
SQL is used to update, delete, retrieve, and organize data in relational database management systems (RDBMS). Oracle and Microsoft SQL Server are some examples of RDBMS that use SQL as their query language. Although some systems may have their own flavors (additions to SQL), the basic SQL commands are common across all of them:
- CREATE TABLE statements to get started creating the tables that’ll hold your data
- INSERT INTO statements to insert data into a table
- SELECT statements to select specific records from tables
- UPDATE and DELETE statements to update or delete data already in a table
- WHERE clauses are used with SELECT to specify what data is being searched for
- AND and OR operators are used in conjunction with WHERE to filter records based on more than one condition
- NOT operators return a record if the condition is not true
- Aggregate functions perform calculations on a set of values and return one value
- Joins (inner join, left join, right join, full outer join) are used to combine rows from two or more tables
- Wildcard characters are used to substitute characters when specifying a pattern to search for in a table column
- Constraints are rules for data: NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY, INDEX, DEFAULT
- Data types. You should know the basic data types
Skills Needed to Learn SQL
SQL databases, also known as relational databases, are like Excel spreadsheets on steroids. Using databases, you can easily merge and filter data to only see what you require. The size and the many connections between the data require the user to have the following basic skills:
- Numerical skills. A foundation in probability and statistics will help inform your analysis and help you to make sense of the data.
- Regular expressions. Practice with Regex will help you to narrow searches to records having certain alpha-numerical patterns. See this article on Regex in SQL.
- Analytical skills. You’ll often be grouping relevant data in an informative and efficient way. SQL tables consist of columns (with the column name, data type, and other attributes of your choosing) and rows (containing the individual records).
Why You Should Learn SQL
Information is gathered every time you swipe your credit card at a store or a transportation card at a train station. Data is also collected when you visit a website; even lingering on a picture on a website creates data that can be recorded. Businesses that want to make effective marketing decisions look at data.
A supermarket may want data on previous years’ sales, weather reports, and certain social media hashtags to determine on which date to display their BBQ-related items, for example. Researchers may want to gather thousands of hours’ worth of data to point out trends amongst certain species and learn more about their behavior. All of this to say one thing: there are many, many ways that data can be used!
Data is now widely available, and anyone interested in it can use it to inform their decisions. Our digital footprint is growing and with it, terabytes of data on human, wildlife, and even space activity are being created every day.
How Long Does it Take to Learn SQL?
It takes only a few weeks (two to three on average) to learn the basics of SQL. The hardest part is learning how to organize your data in the best possible way. This is indeed a skill that can only be acquired with lots of practice!
After learning the basics, the rest of your training will pretty much consist of practicing what you learned through exercises. Learning to think in terms of minimizing the repetition of data, organizing tables efficiently, and testing to see if your setup works as it was intended to is what takes time; it can only be done through practice exercises!
Learning SQL: A Study Guide
There’s definitely a lot to cover since there are many flavors of SQL. The good news is that once you know one, you can learn other SQL flavors easily. The following resources are handy for someone who wants to go over the basics of SQL as well as dive in and do some practice queries. In more advanced applications, you can pair SQL with other languages such as Python.
- Resource type: Online tutorials
- Price: Free
- Audience: Beginner
W3schools has a section on how to learn SQL in different database systems (MySQL, SQL Server, Postgres, Microsoft Access, etc) with examples for each topic. W3schools is a good starting point because they touch on all the basics (SQL syntax, joins, hosting, keys, keywords, etc). They also have a paid alternative ($95) in which you receive a certificate upon completion.
- Resource type: Online tutorial
- Price: Free
- Audience: Beginner
Codecademy has a free online course to help get you started with the basics of SQL. It includes four projects to help you get hands-on practice under your belt. This course covers queries, aggregate functions, and data manipulation on multiple tables. There’s an optional, paid “pro” version in which you obtain a certificate.
- Resource type: Online course
- Price: $12.99
- Audience: Intermediate
This LearnSQL course is for people familiar with the basics. It covers more advanced features (ROLLUP, CUBE, and GROUPING SETS clauses), and time-saving querying techniques (window functions, common table expressions, recursive queries). This 38-hour course comes with a code editor, real datasets, problem-solving exercises, mentor, and tech support. After completing the course, you will receive a certificate you can post to your LinkedIn profile and other sites. Better to tackle this course after you feel comfortable with the basics!
- Resource type: Online course
- Price: $59.99
- Audience: Beginner
This course covers queries, updates, grouping functions, joins, and other basic concepts. No knowledge of SQL is required and the course guides you through the setup needed. Toward the latter part of the course, you’ll explore advanced topics based on real-world applications. This course has had over 200,00 students, maintains a high rating, and was recently updated.
Communities for People Studying SQL
Getting a community to help you in your learning journey as well as in your professional career is key. When you surround yourself with people who use SQL, it is easier to chart a road map for your career and decide what you need to learn to succeed in your particular data field. Making connections can be as easy as joining an online chat channel. You never know where the perfect job offer could come from!
Joining online communities is a convenient way to get involved; you can participate and maintain communication from the comfort of your home. There are various Discord servers tagged with SQL. The SQL server caters to learners and teachers. There’s also a Slack channel called the SQL Server Community. People of all experience levels participate.
Also, a lot of the meetups and conferences that were traditionally held in person have moved online.
If you prefer meeting in person you can check SQL-related meetup groups in your area. Some of these groups are also currently opting for online meetups. This data community list contains several data communities arranged by country, state, and topic.
Attending conferences is useful in many ways. You can network with people with similar professional interests, learn about industry trends, and get to know what’s on the horizon for SQL. SQL Server Live! is an SQL conference that caters to professionals who want to get more out of their SQL software. Other conferences are more about topic exploration. A good way to find out about conferences in your area is by joining online communities and mailing lists.
Will Learning SQL Help Me Find a Job?
SQL is a necessary skill if you want to delve into a career in data science such as database development or data analysis. However, you do not have to be in data science to use SQL; researchers, quality assurance testers, and business analysts also make use of SQL. Knowledge of SQL will help you develop and maintain databases.
SQL is used by companies like Google, Netflix, Airbnb, and Amazon. That should be enough to know that SQL skills are in high demand!
SQL is used in relational databases. You may have heard of NoSQL databases such as MongoDB, which are document-oriented and lauded for their scalability. MongoDB does not use SQL. Although NoSQL is trending, that does not mean that SQL is not important or outdated. In fact, both can be helpful for different reasons!
For example, unlike SQL, MongoDB does not support joins. As a database administrator, you will be expected to know which of the two—SQL or NoSQL—better suits the company’s needs.
According to this ScaleGrid survey of database trends, SQL databases are still ahead of NoSQL in terms of popularity. After acquiring sufficient experience, you may consider enrolling in a bootcamp, completing a certification course, building a portfolio of your SQL projects, or a combination of these to get employers’ attention.
Conclusion: SQL is a Skill Worth Learning!
There are many fun ways to use data. There are tons of data available on a myriad of topics, and if you know how to search through it you can glean some very powerful insights. SQL is one tool you can use to interpret and organize some of that data. This is why SQL is a very marketable skill. The best thing about it all is that while it is not very hard to learn, it can take you far in your career.
After learning the basics, the next step is to learn the skills that are specific to the career track you want to follow. No matter which career you choose to pursue, you probably want to work on data projects so you can show what you have learned during job interviews. Learning different flavors of SQL (such as SQL Server, PostgreSQL, Oracle, MySQL, and SQLite) and listing them on your resume will also be advantageous.
All major companies rely on data to inform their business decisions. Holding a position in which you are in charge of this data is a big deal! Even if you are in a technical role, you can still wield your SQL knowledge to produce graphs on software such as Tableau. Having a visual supported by real data is a strong and impactful way to drive a point.