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

WHERE: picking the rows you need

038 min

Usually you do not need every row of a table. “Only 2nd-year students”, “products cheaper than 100,000” — conditions like these are written with WHERE.

The pattern

SELECT columns FROM table WHERE condition;

The database checks every row: if the condition is true, the row goes into the result; if not, it is left out.

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

Comparison operators

Operator Meaning Example
= equal course = 2
<> or != not equal city <> 'Toshkent'
> / < greater / less salary > 9000000
>= / <= greater or equal / less or equal score >= 86
university· Try changing it
SELECT first_name, last_name, salary FROM teachers WHERE salary > 12000000;

Text and dates go in quotes

Numbers are written without quotes; text and dates go in single quotes:

university· Try changing it
SELECT first_name, last_name FROM students WHERE city = 'Samarqand';

Forget the quotes and the database takes Samarqand for a column name and complains that there is no such column. Dates are written as 'year-month-day':

university· Try changing it
SELECT first_name, last_name, hire_date FROM teachers WHERE hire_date >= '2020-01-01';

Several conditions: AND, OR, NOT

  • AND — both conditions must hold;
  • OR — at least one must hold;
  • NOT — turns a condition around.
university· Try changing it
SELECT first_name, last_name, city, course
FROM students
WHERE course = 1 AND city = 'Toshkent';

When you mix AND and OR, use brackets — otherwise AND is applied first and the result may not be what you expect:

university· Try changing it
SELECT first_name, city, course
FROM students
WHERE course = 4 AND (city = 'Buxoro' OR city = 'Navoiy');
1Exercise

Show first_name and last_name of the students who study on a grant (funding = 'grant').


2Exercise

Show first_name and city of the 3rd-year students who are not from Tashkent (city is not 'Toshkent').


Remember

  • WHERE picks rows by a condition.
  • Text and dates go 'in single quotes', numbers go without.
  • Mixing AND and OR? Use brackets.
Previous lessonYour first SELECTNext lessonIN, BETWEEN, LIKE and NULL

Contents

  • The pattern
  • Comparison operators
  • Text and dates go in quotes
  • Several conditions: AND, OR, NOT
  • Remember
LearnPracticeProblemsArenaLeaderboard

SQLab