HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to SQL (SELECT)Tables (CREATE & INSERT)Filtering (WHERE)Sorting & LimitingAggregate FunctionsUpdate & DeleteJoins (JOIN)
REFERENCE
📖 Overview
🔎 Querying (SELECT)
SELECTSELECT *DISTINCT
🗃️ Creating a Table
✏️ Inserting & Modifying Data
🧲 Filtering (WHERE)
🔢 Sorting & Limiting
📊 Aggregate Functions
🔗 Joins (JOIN)
SQL›REFERENCE›Querying (SELECT)
🔎

Querying (SELECT)

The basis of data retrieval.

CommandDescription
SELECTRetrieves data from a table.
SELECT *Retrieves all columns.
DISTINCTRemoves duplicates.

SELECT

Try it yourself →

Retrieves data from a table.

Syntax

SELECT column FROM table;

Description

Specifies which columns you want and which table to fetch from. * brings all columns.

Example

CREATE TABLE person(name TEXT, age INTEGER);
INSERT INTO person VALUES ('Alex', 36), ('Linus', 54);
SELECT name FROM person;

Expected output

Alex
Linus

When to use?

Data reading — SQL's most commonly used command.

Common mistakes

  • ⚠️ A semicolon (;) is required at the end of the command.

SELECT *

Try it yourself →

Retrieves all columns.

Syntax

SELECT * FROM table;

Description

The * wildcard selects all columns in the table.

Example

CREATE TABLE k(id INTEGER, name TEXT);
INSERT INTO k VALUES (1, 'Alex');
SELECT * FROM k;

Expected output

1|Alex

When to use?

Quick look (it is better to select only the necessary columns in production).

DISTINCT

Try it yourself →

Removes duplicates.

Syntax

SELECT DISTINCT column FROM table;

Description

Shows duplicate values only once (unique values).

Example

CREATE TABLE c(city TEXT);
INSERT INTO c VALUES ('Milan'), ('Milan'), ('Berlin');
SELECT DISTINCT city FROM c ORDER BY city;

Expected output

Berlin
Milan

When to use?

Listing unique values.

HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code