SQLab
LearnPracticeProblemsArenaLeaderboard
© 2026 SQLab · Tashkent
SQLab

Learn SQL right in the browser — nothing to install.

Platform

  • Learn
  • Practice
  • Problems
  • Arena
  • Leaderboard

Who it is for

  • Students
  • Teachers
  • Universities
© 2026 SQLab. All rights reserved.Made in Uzbekistan, for students.
LearnPracticeProblemsArenaLeaderboard
0/26

Basics

  • What is a database?
  • Your first SELECT
  • WHERE: picking the rows you need
  • IN, BETWEEN, LIKE and NULL
  • Sorting, LIMIT and DISTINCT

Calculations

  • Expressions, functions and CASE
  • Working with dates
  • COUNT, SUM, AVG, MIN, MAX
  • GROUP BY and HAVING

Joining tables

  • Keys and relations
  • INNER JOIN
  • LEFT JOIN and rows without a match
  • Several tables and the self join

Advanced queries

  • Subqueries
  • UNION, INTERSECT, EXCEPT
  • WITH: named queries
  • Window functions

Creating and changing tables

  • CREATE TABLE: types and constraints
  • INSERT, UPDATE, DELETE
  • ALTER, DROP, TRUNCATE
  • Designing a database well

Going professional

  • Indexes and EXPLAIN
  • Transactions and ACID
  • Views: saved queries
  • Functions, procedures and triggers
  • Users, privileges and backups
Learn/Basics

Your first SELECT

027 min

SELECT is the most used command in SQL. It reads data from the database and never changes it.

The pattern

SELECT columns FROM table;
  • SELECT — what you want to see (columns);
  • FROM — where it comes from (table);
  • ; — the command ends here.

All columns: *

The asterisk means “every column”. Handy for a quick look at what a table holds:

university· Try changing it
SELECT * FROM faculties;

In real projects, be careful with SELECT *: if a column is added to the table later, the result changes, and data you do not need gets loaded too. Naming the columns you need is a good habit.

Only the columns you need

Columns are separated by commas and come out in exactly the order you wrote them:

university· Try changing it
SELECT last_name, first_name, course FROM students;

Case and spacing

SQL keywords can be written in any case: SELECT, select, Select — all the same. They are usually written in capitals so the query is easier to read.

A long query can be split over several lines — the database treats everything up to ; as one command:

university· Try changing it
SELECT first_name,
       last_name,
       city
FROM students;

Renaming a column: AS

You can change the heading of a column in the result. This is called an alias:

university· Try changing it
SELECT first_name AS name, last_name AS surname FROM students LIMIT 5;

If an alias contains a space or special characters, put it in quotes:

In PostgreSQL use double quotes: AS "Student name". Single quotes ('…') are only for text values.

A calculated column

SELECT can contain expressions, not just columns. For example, teachers’ yearly salary:

university· Try changing it
SELECT first_name, last_name, salary * 12 AS yearly FROM teachers;
1Exercise

From the subjects table, show the name (name) and number of credits (credits) of every subject.


2Exercise

From the teachers table, show the teachers’ last name (last_name) and position (position).


Remember

  • SELECT columns FROM table; is the basic pattern for reading data.
  • * means every column, but at work it is better to name the ones you need.
  • AS gives a column of the result a new name.
Previous lessonWhat is a database?Next lessonWHERE: picking the rows you need

Contents

  • The pattern
  • All columns: *
  • Only the columns you need
  • Case and spacing
  • Renaming a column: AS
  • A calculated column
  • Remember
LearnPracticeProblemsArenaLeaderboard

SQLab