Name

SELECT — Query data from the database

Syntax

image with no caption

result-column:

image with no caption

join-source:

image with no caption

single-source:

image with no caption

ordering-term:

image with no caption

compound-operator:

image with no caption

Common Usage

SELECT * FROM tbl;
SELECT name FROM employees WHERE employee_id = 54923;
SELECT 5 + 6;

Description

The SELECT command is used to query the database and return a result. The SELECT command is the only SQL command capable of returning a user-generated result, be it a table query or a simple expression. Most consider SELECT to be the most complex SQL command. Although the basic format is fairly easy to understand, it does take some experience to understand its full power.

All of Chapter 5 is devoted to the SELECT command.

Basic format

The core SELECT command follows a simple pattern that can be roughly described as SELECT output FROM input WHERE filter. The output section describes the data that makes up the result set, the input section describes what tables, views, subqueries, ...

Get Using SQLite now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.