CodeBlanks Logo Icon CodeBlanks

What is SELECT?

Learn that SELECT pulls data from a table.

What is SELECT?

The SELECT statement retrieves data from a database. It lets you choose rows and columns from a table. It is the most fundamental SQL command and appears in almost every query.

A SELECT statement has at least two parts: SELECT says which columns you want, and FROM says which table to read. The result comes back as a table.

What is SELECT? — details

The simplest SELECT query looks like this:

SELECT name, price
FROM products;

Here the name and price columns are pulled from the products table. You separate column names with commas; no comma after the last column. A semicolon ends the statement. The result table follows the column order of the query and includes every row of the table.

Practice What is SELECT?

Write a query that selects the name and price columns from the products table.

Starter code

query.sql
-- write columns and table
SELECT
FROM

Sample solution

query.sql
SELECT name, price
FROM products

Expected output

name  price
Kalem 5
Defter 12

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which statement reads data?

  • SELECT Correct answer
  • DELETE
  • INSERT
  • DROP

Explanation: SELECT is used to read data.

2 SELECT keyword

Question
-- sorguyu tamamla
____ name, price
FROM products;
Answer
-- sorguyu tamamla
SELECT name, price
FROM products;

Explanation: Every query that reads data starts with SELECT, followed by the columns you want.

3 What is SELECT: match the terms

Term Meaning
SELECT choose columns
FROM specify table
WHERE filter rows
ORDER BY sort

All lessons in Beginner