Hone

Lessons · SQL · SELECT basics

Asking a table for columns

SELECT names the columns you want, FROM names the table. That is a complete question.

Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.

What it is for

Every report, export, dashboard tile and API endpoint that reads a database starts with SELECT ... FROM.

How to think about it

What do I want to see, and where does it live? Say what you want to see, then where it lives. Name the columns rather than using * so the result is stable when the table changes.

Worked example

SELECT title, year
The columns I want to see.
FROM films;
The table they live in.

Your turn

Get every film's title.

SELECT  FROM films;

The trap

SELECT * in application code. A new column breaks the code that assumed the old shape.

Practise SELECT basics on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.