The term SQL stands for Structured Query Language. A query language is a programming language that accesses data stored in relational databases. That term may sound technical, but don’t worry — SQL’s structure is relatively simple. Here’s an example:
SELECT firstname, lastname FROM customers WHERE state="California";
The query above is pretty direct and straightforward. You can probably figure out what it’s supposed to do, even without knowing the language.
If you guessed it was supposed to retrieve the first and last name of every customer from California, you are correct. As you can see, SQL is pretty easy to grasp, even for beginners. Read on for more information about how it works and how it’s used.
What are relational databases?
Relational databases are software used to store structured data. This data is stored in tables. If you’re familiar with spreadsheets, think of a table as one worksheet in a spreadsheet.
Each table has columns and rows. Each column holds a specifically named value, and each row contains a record. For example, a table of
customers would have columns like
The relational part means that one table can relate to another table. If we have a customers table, we could also have an orders table. By adding a customer id column to our orders table, we can relate our order records to our customer records.
Relational databases give you the power to structure your data however you choose, and SQL gives you the power to access that data however you choose.
You can choose from quite a few relational databases, but they all use a variation of SQL. Some common relational database engines include:
How SQL works
Imagine you own an e-commerce site, and you store your data in a relational database like PostgreSQL or SQLite. In your database, you have three tables:
order_items. Using SQL, you can pull related data from each table.
Say you wanted to query the last name of all your customers in Washington. In that case, you could use a query similar to our first example:
SELECT last_name FROM users WHERE state="Washington";
This would give you data from one table, which is useful but doesn’t show the full range of SQL’s capabilities. What if you wanted to get all the orders from your customers in Washington? Your query would look something like this:
SELECT * FROM users JOIN orders ON orders.user_id = users.id WHERE state="Washington";
Again, the syntax almost reads like a natural language. The asterisk basically means “every column,” so this query will give you all the data you need.
SQL also has powerful functions like
SUM() that apply calculations to data. So, if you wanted to take SQL even further, you could include the order_items table in the query and use SUM to calculate the total value of all the orders from your customers in Washington. And this is just the beginning of all the things you can do with SQL. For an expanded list of SQL’s functions, check out this list of SQL commands.
Careers that use SQL
As you can see, SQL is a vital tool in the collection and manipulation of data. That, coupled with the various ways businesses use data, makes it a valuable skill for both technical and non-technical roles. Let’s take a look at some of the different careers that use SQL.
Data science professionals like data scientists and data analysts collect, organize, and manipulate a business’ data to find actionable insights. To get the data they need, they often have to use SQL to retrieve it from a relational database.
Business analysts and marketers need insights to guide businesses toward better processes, products, and services. Sometimes, they don’t have time to wait for data scientists to provide them. With SQL, they can go directly to the source and write queries that will give them the insights they need in a matter of minutes instead of days or weeks.
Database administrators deal with data all day long. A database administrator (or DBA) manages the database engines that hold an enterprise’s data. They must possess extensive knowledge of both SQL and database software.
Knowing SQL will also give you a step up in most programming roles. Whether you want to be a software engineer or a web developer, you’ll likely have to access a relational database at some point in your career. To do that, you’ll need to know SQL.
Learn more about SQL
While simple, SQL is a powerful programming language and valuable addition to almost any skill set. Ready to get started? Our Learn SQL course will teach you the basics of querying and data manipulation.
After you’ve learned its basics, we have several courses that teach you how to use SQL to advance in your career. Considering a career in data science? Learn how to analyze data with SQL. More interested in its non-technical applications? Check out Learn Intermediate SQL for Marketers and Product Managers.