BETWEEN

Numbers: bigger, smaller, between

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

Pick books by number: from a year on, or between two years.

Use >, <, >= and BETWEEN in WHERE. Numbers have no quotes.

The database
10 rows
book_idtitleauthorgenreyearpages
1Gone GirlGillian FlynnThriller2012419
2Angels & DemonsDan BrownThriller2000616
3The Fellowship of the RingJ.R.R. TolkienFantasy1954423
4Pride and PrejudiceJane AustenRomance1813432
5Charlotte's WebE.B. WhiteChildren1952184
6Harry Potter and the Prisoner of AzkabanJ.K. RowlingFantasy1999317
7MockingjaySuzanne CollinsScience Fiction2010390
8The Time MachineH.G. WellsScience Fiction1895118
9The Lion, the Witch and the WardrobeC.S. LewisFantasy1950172
10FrankensteinMary ShelleyHorror1818280
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 BETWEEN works

  • Which comparisons are there?

    = equal, <> not equal (!= works too), > bigger, < smaller, >= bigger or equal, <= smaller or equal.

  • Does "2000 or later" include 2000?

    Yes, so it's year >= 2000. year > 2000 leaves out a book from exactly 2000. Words like "at least", "or more" and "up to" all include the limit.

  • What does BETWEEN do?

    WHERE year BETWEEN 1950 AND 1999

    It keeps values from 1950 to 1999, and both ends are included. It's the same as year >= 1950 AND year <= 1999.

  • Do numbers need quotes?

    No: year >= 2000, not year >= '2000'. Quotes are for text.

  • How is this like Excel?

    The same test as =IF(E2>=2000, ...), or a number filter on the year column.

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