Learn the Basics of SQL Syntax and How to Interact with Databases¶
If you work in a corporate environment—whether as a data analyst, a business intelligence professional, or a curious user exploring company data—you’ll likely encounter SQL (Structured Query Language) sooner rather than later. SQL is the standard language for working with relational databases. Even if you’re not building tables or designing complex databases from scratch, knowing how to read and query data can be invaluable. In this post, we’ll introduce the basics of SQL, focusing on the most common use case in many companies: running read-only queries to find and understand the data you need.
What is SQL?¶
SQL (often pronounced “ess-queue-ell”) is a language designed to manage and interact with data stored in relational databases. These databases organize information into tables—structured collections of rows and columns that resemble spreadsheets. Unlike spreadsheets, however, databases are optimized for quickly retrieving, filtering, sorting, and summarizing large volumes of data. SQL provides a clear and concise way to query this data, ensuring that you can get the insights you need, efficiently and accurately.
Key Features of SQL¶
- Relational Structure: Data is stored in tables that are linked together through defined relationships.
- Declarative Language: Instead of telling the system how to find the data, you describe what data you want—SQL figures out the "how."
- Widespread Adoption: Almost all major relational database systems—like Microsoft SQL Server, Oracle, MySQL, and PostgreSQL—support a common core of SQL syntax.
Why Learn SQL if You’re Just Reading Data?¶
In many corporate settings, you might never need to create new tables or alter the database’s structure—those tasks are often reserved for database administrators (DBAs) or backend developers. Instead, your primary goal is likely to retrieve data that’s already stored in established, secure databases.
For example:
- Business Analysts might pull sales figures or customer lists for reporting.
- Data Scientists might fetch large datasets to run models or analyze trends.
- Marketers might query customer engagement records to refine campaigns.
In these scenarios, learning how to write SQL queries to select and filter data is the most critical skill. Think of SQL as your gateway to the organization's data vault: you don’t own the vault or rearrange its shelves, but you need to know how to find the right box inside it.
Core Database Concepts for Reading Data¶
Even if you’re only reading data, understanding some basic database concepts will help you navigate effectively:
- Tables: Think of tables like spreadsheets within the database. Each table focuses on a particular type of data—like a
customers
table or atransactions
table. - Columns: These define the types of information each record in the table holds. For a
customers
table, columns might becustomer_id
,first_name
,last_name
, andemail
. - Rows: Each row represents a single data record. One row in the
customers
table corresponds to one customer. - Primary Keys and Foreign Keys: These are how databases keep data organized and connected. A primary key uniquely identifies a row in a table, while a foreign key references a primary key in another table, linking related data. You don’t have to create or change these, but knowing they exist helps you understand how tables relate to each other.
Connecting to the Database¶
How you connect depends on your company’s internal tools and policies:
- Internal BI Tools: Many companies provide a business intelligence tool (like Tableau or Power BI) or a SQL client application (like SQL Server Management Studio) pre-configured to access certain databases.
- Login Credentials: You’ll typically have a username and password, and possibly some form of single sign-on (SSO). Often, you’ll have restricted permissions—enough to read data but not to alter tables.
- Pick a Database and Schema: Once connected, you might have to choose from multiple databases or schemas (organizational “folders” for tables) to find what you need.
Your IT or database team will likely guide you on where to connect and which tables you can access.
The Most Important SQL Command: SELECT¶
As a read-only user, the SELECT
statement is your bread and butter. This command allows you to retrieve the data you need from one or more tables.
Next¶
Next we'll cover how to connect and some types of queries you can expect to run to get started.