-
DAYS
-
HOURS
-
MINUTES
-
SECONDS

Free Beginners SQL Course!

SQL Tutorial for SQL Server

Welcome to Essential SQL Online SQL Tutorial. Use this page to get started learning SQL.

SQL Tutorial Overview

Use SQL (Structured Query Language) to query a relational database. You use SQL to “tell” the database what results that you would like to see.

Since the database stores its data in tables, which are made up of rows and columns, a typical SQL statement’s purpose is to describe what table to query and which columns to return.

All of the examples in this tutorial are based on PizzaDB. You can get the script to build the PizzaDB here.

Below is the Customer table. We’re going to use this for several examples.

Customer Table used for SQL Tutorial

Notice a table consists of rows and columns. In this case, each row represents one customer. The columns represent their attributes, such as their name, or the city they live in.

When writing queries using SQL, we need to specify both the columns we want to see, and the query returns the rows which match.

SQL Tutorial Example

Here is a simple SQL query.

SELECT LastName, City FROM Customer
/* Answer */
SELECT LastName, City
FROM Customer

In this SQL Tutorial example we are querying the Customer table and return for each customer their last name and city.

You can try the query for yourself.  Just click Run Query

In fact, wherever, you see the box above, you can run the statement shown, or modify it to experiment and learn.

Now and then, we’ll ask you to write SQL! When you get stumped click on Show Answer to reveal what we wrote for the SQL Tutorial.

Tutorial Topics

Click on a topic to the right to view it. You can start from the top and do the topics in sequence, of if you wish, just skip ahead to a topic you want to learn.

The main topics covered are:

In either case, the SQL tutorial topics are just the right size for you to learn a concept within several minutes.

In addition to the topics there is also a SQL Server Reference.

Additional Resources

In addition to what we have here in our SQL tutorial, I would also recommend these popular articles from our blog: