Back to Yugabyte Db

BETWEEN

community/learn/content/01-SQL-Basics/02-fundamentals/08-between.md

2026.1.0.0-b25630 B
Original Source

SELECT with BETWEEN

In this exercise we will query the products table and find all the products who have a product_id between 10 and 20.

SELECT product_id,
       product_name,
       quantity_per_unit
FROM products
WHERE product_id BETWEEN 10 AND 20

This query should return 11 rows

SELECT with NOT BETWEEN

In this exercise we will query the products table and find all the products who have a product_id that is not between 10 and 20.

SELECT product_id,
       product_name,
       quantity_per_unit
FROM products
WHERE product_id NOT BETWEEN 10 AND 20

This query should return 66 rows