SELECT

Your first SELECT

SQLite in your browser
Lesson concept What you'll do
1 / 5

Ask the books table for a few of its columns.

SELECT names the columns and FROM names the table. Every row comes back.

The database
9 rows
book_idtitleauthorgenreyearpages
1Pride and PrejudiceJane AustenRomance1813432
2The Great GatsbyF. Scott FitzgeraldFiction1925180
3DraculaBram StokerHorror1897418
4MockingjaySuzanne CollinsScience Fiction2010390
5The Time MachineH.G. WellsScience Fiction1895118
6Angels & DemonsDan BrownThriller2000616
7Charlotte's WebE.B. WhiteChildren1952184
8The Fault in Our StarsJohn GreenRomance2012313
9The Fellowship of the RingJ.R.R. TolkienFantasy1954423
Click a name to type it
Your query
 
Hint: click the green edit button on the board, or type it yourself
Query output Ready to run

Run your query to see the result table.

Press the green Run button or Ctrl+Enter.

Study notes

How SELECT, FROM works

  • What is SQL?

    SQL (say "sequel" or "S-Q-L") is the language for asking a database for data. Libraries, banks, shops and apps keep their data in databases, and analysts use SQL to get answers out of them.

  • What is a table?

    A table is like a sheet with a name: columns with headings, and one row per thing, such as a book or a loan. Every value in a column is the same kind: text, a whole number or a decimal.

  • How do I write a SELECT?

    SELECT title, author FROM books;

    List the columns after SELECT, with commas between them, then the table after FROM. The semicolon ends the query.

  • What does SELECT * do?

    SELECT * FROM books; shows every column. It's handy for a first look at a table, but in real work list the columns you need: it's clearer and faster.

  • Do capital letters matter?

    Not for keywords: select works the same as SELECT. Writing keywords in capitals is a habit that makes queries easier to read.

  • How is this like Excel?

    Picking columns is like hiding the ones you don't need, or CHOOSECOLS. The difference: SQL never changes the table, it just shows you a result.

Know someone fighting with a spreadsheet? Send them this page.