Back to Yugabyte Db

IN

community/learn/content/01-SQL-Basics/02-fundamentals/07-in.md

2026.1.0.0-b29836 B
Original Source

SELECT with an IN clauses

In this exercise we will query the shippers table and return only the rows that have a shipper_id of 1, 2, 3 or 4.

SELECT *
FROM shippers
WHERE shipper_id IN (1,2,3,4);

This query should return 4 rows

SELECT with a NOT IN clause

In this exercise we will query the shippers table and return all the rows, except those that have a shipper_id of 3 or 4.

SELECT *
FROM shippers
WHERE shipper_id NOT IN (3,4);

This query should return 4 rows

SELECT with an IN clause in a subquery

In this exercise we will query the orders table and return all the rows using a subquery to find all the orders who have an order_date of 1998-05-06.

SELECT
   customer_id
FROM
   orders
WHERE
   CAST (order_date AS DATE) = '1998-05-06';

This query should return 4 rows