SQL — Structured Query Language — is the standard language for working with relational databases. You do not need to be a programmer to use SQL. Many analysts, coordinators, and office workers use basic SQL every day to read and summarize data. This lesson introduces the fundamentals.
What Is SQL?
SQL is a language designed specifically for working with relational databases. You write SQL statements to ask questions of the database, retrieve data, and (with appropriate permissions) modify data. SQL is not a programming language in the traditional sense — it is a declarative language: you describe what you want, and the database figures out how to get it.
SQL dialects vary slightly between database systems. The core SELECT syntax covered in this lesson works across most relational databases, but some functions and syntax details differ. Always check the documentation for the specific system you are using.
Reading Data vs Changing Data
SQL statements fall into two broad categories:
- Read statements (SELECT). These retrieve data without changing anything. They are safe to run and are the focus of this lesson.
- Data-changing statements (INSERT, UPDATE, DELETE, and structural commands). These modify data or database structure. They require care, appropriate permissions, and should never be run against a live organizational database without authorization and a tested plan.
When learning SQL, practice in an authorized learning environment — not against production data.
The SELECT Statement
The most common SQL statement is SELECT. It retrieves rows from a table.
SELECT program_name, start_date
FROM programs
ORDER BY start_date;
This query retrieves the program_name and start_date columns from the programs table, sorted by start date from earliest to latest. The semicolon ends the statement.
Filtering with WHERE
The WHERE clause filters which rows are returned.
SELECT program_name, capacity
FROM programs
WHERE capacity >= 20
ORDER BY capacity DESC;
This retrieves programs with a capacity of 20 or more, sorted from largest to smallest capacity. DESC means descending order; ASC (the default) means ascending.
Selecting All Columns
You can use SELECT * to retrieve all columns from a table. This is convenient for exploration but should be avoided in production queries — it retrieves more data than needed and breaks if the table structure changes.
Whitespace and Readability
SQL ignores extra whitespace and line breaks. Writing each clause on its own line is a convention that makes queries easier to read and debug. Both of these are equivalent:
SELECT program_name FROM programs WHERE capacity >= 20;
SELECT program_name
FROM programs
WHERE capacity >= 20;
Safe Learning Practices
- Practice on sample or test data, not on live organizational databases.
- Start with SELECT statements before attempting any data-changing commands.
- Understand what a query will do before running it.
- Ask for guidance from a database administrator before running unfamiliar commands.
A SELECT statement cannot change data. It is a read-only operation. Learning to write SELECT queries is safe and is the most useful SQL skill for most non-developer roles.
Key Takeaways
- SQL is a language for working with relational databases — declarative, not procedural.
- SELECT retrieves data; it does not change anything.
- FROM specifies the table; WHERE filters rows; ORDER BY sorts results.
- SQL dialects vary between database systems — check the documentation for your system.
- Practice on authorized test data, not on live organizational databases.
- beginner SQL SELECT tutorial
- SQL WHERE clause examples
- SQL ORDER BY explained
- SQL for non-programmers