# SELECT in T-SQL: an overview

A SELECT statement asks the database a question and gets back a table of answers; T-SQL is SQL Server's version of SQL.

Novice · T-SQL · SQL · Updated November 15, 2026

By Gregor Dzierzon

## After this lesson you can

- Explain what a SELECT query does and what it returns

## Key takeaways

- SQL is the language of relational databases, and T-SQL is SQL Server's version of it.
- A `SELECT` statement, or query, asks the database a question and gets back a result set: a table of rows and columns.
- In SQL you describe what you want, not how to find it; the database works out how to search.
- A `SELECT` only reads: the data in the tables stays exactly as it was.

**SQL** (Structured Query Language) is the language for working with relational databases. Every relational database understands it: SQL Server, MySQL, PostgreSQL, Oracle. Each adds a few features of its own. SQL Server's version is called **T-SQL** (Transact-SQL), and it's what you'll write in this course.

## Asking questions

You get data out of a database with a `SELECT` statement. A `SELECT` is also called a **query**, because you're querying the database: asking it a question.

- *Which customers are in the UK?*
- *What are our ten most expensive products?*
- *Which orders were placed last week?*

Each question becomes a `SELECT` statement. The database works out the answer and sends back a **result set**: a table of rows and columns, just like the tables it stores.

## Describe what you want, not how to get it

In C#, you tell the computer **how** to do something, step by step: loop through the customers, check each one's country, add the matches to a list. SQL is different. You describe **what** you want, and the database works out how to find it:

```sql
SELECT CompanyName, City
FROM Customers
WHERE Country = 'UK';
```

Read it almost as English: *select the company name and city, from the customers, where the country is the UK.* There's no loop in sight: the database decides how to search, and it's very good at it.

## Think of a report

It helps to think of each query as a small report. You choose which columns go in it, which rows, and in what order. The tables don't change: a `SELECT` only reads. You can run as many queries as you like, and the data stays exactly as it was.

## Do it: turn a question into a query

The sales team asks a question: *Which customers are in Spain?* Turn it into a `SELECT`, the way the lesson turned *Which customers are in the UK?* into one.

The `Customers` table (the **Tables** tab shows the SQL that makes it) has these rows:

| CompanyName | City | Country |
|---|---|---|
| Bólido Comidas preparadas | Madrid | Spain |
| Around the Horn | London | UK |
| FISSA Fabrica Inter. Salchichas S.A. | Madrid | Spain |
| Furia Bacalhau e Frutos do Mar | Lisboa | Portugal |
| Galería del gastrónomo | Barcelona | Spain |
| Romero y tomillo | Madrid | Spain |

Your query should give exactly these rows, in any order:

| CompanyName | City |
|---|---|
| Bólido Comidas preparadas | Madrid |
| FISSA Fabrica Inter. Salchichas S.A. | Madrid |
| Galería del gastrónomo | Barcelona |
| Romero y tomillo | Madrid |

**Your job:** write one `SELECT` query that answers the question.

- Show two columns, `CompanyName` and `City`, in that order.
- Read them from the `Customers` table.
- Keep only the rows whose `Country` is `'Spain'`.

Practiced live on the lesson page: write the SQL right there and check it.

## Check yourself

1 question to try on the lesson page.

## So what

`SELECT` is the statement you'll write most as a developer: every page that shows data, from a product list to an order history, starts with a query.

## Key terms

- [Structured Query Language (SQL)](https://www.ask-codey.com/glossary/structured-query-language-sql)
- T-SQL
- [Result Set](https://www.ask-codey.com/glossary/result-set)

## Cheat sheets

- [SELECT in T-SQL: an overview](https://www.ask-codey.com/cheat-sheets/select-in-t-sql-an-overview-cheat-sheet)

Source: https://www.ask-codey.com/lessons/select-in-t-sql-an-overview
