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

IN, BETWEEN, LIKE and NULL

048 min

You can do a lot with = and >, but SQL has four more tools that make conditions short and precise.

IN — one of a list

Instead of several ORs:

university· Try changing it
SELECT first_name, last_name, city
FROM students
WHERE city IN ('Buxoro', 'Navoiy', 'Urganch');

This is the same as city = 'Buxoro' OR city = 'Navoiy' OR city = 'Urganch', just shorter. The opposite is NOT IN.

BETWEEN — within a range

university· Try changing it
SELECT first_name, last_name, score
FROM grades JOIN students ON students.id = grades.student_id
WHERE score BETWEEN 90 AND 100;

BETWEEN a AND b includes both ends, so it means >= a AND <= b. It works for dates too:

university· Try changing it
SELECT first_name, last_name, birth_date FROM students
WHERE birth_date BETWEEN '2006-01-01' AND '2006-03-31';

LIKE — matching a pattern

  • % — any number of characters (including none);
  • _ — exactly one character.
university· Try changing it
SELECT first_name, last_name FROM students WHERE last_name LIKE 'Ra%';
Pattern Meaning
'A%' starts with A
'%ova' ends with “ova”
'%bek%' contains “bek”
'_a%' second letter is “a”

In PostgreSQL LIKE is case-sensitive: 'a%' will not find “Aziz”. For a case-insensitive search there is ILIKE: WHERE first_name ILIKE 'a%'.

NULL — no value

NULL means “unknown” or “not filled in”. For example, some students have no phone number on record. NULL equals nothing — not even itself! That is why = NULL does not work:

university· Try changing it
SELECT first_name, last_name FROM students WHERE phone IS NULL;

The right way is IS NULL and IS NOT NULL.

university· Try changing it
SELECT name FROM study_groups WHERE curator_id IS NOT NULL LIMIT 5;
1Exercise

From the products table, show name and brand of the products made by “Apple”, “Samsung” or “Xiaomi”.


2Exercise

Show name and price of the products priced from 1,000,000 to 3,000,000 inclusive.


3Exercise

Show first_name and phone of the customers who have no e-mail on record.


Remember

  • IN (…) — one of a list; BETWEEN a AND b — a range including both ends.
  • LIKE: % — any characters, _ — one character.
  • Only IS NULL / IS NOT NULL work with NULL.
Previous lessonWHERE: picking the rows you needNext lessonSorting, LIMIT and DISTINCT

Contents

  • IN — one of a list
  • BETWEEN — within a range
  • LIKE — matching a pattern
  • NULL — no value
  • Remember
LearnPracticeProblemsArenaLeaderboard

SQLab