product_id and product_name, ordered by product_id.Use these exact table and column names in your query. Open Schema & Data under the editor to preview sample rows.
customers
5 columns
customer_idINTEGERnameTEXTcityTEXTcountryTEXTsignup_dateDATE
products
4 columns
product_idINTEGERproduct_nameTEXTcategoryTEXTpriceREAL
orders
5 columns
order_idINTEGERcustomer_idINTEGERorder_dateDATEamountREALstatusTEXT
order_items
4 columns
order_idINTEGERproduct_idINTEGERquantityINTEGERunit_priceREAL
payments
5 columns
payment_idINTEGERorder_idINTEGERmethodTEXTamountREALpaid_dateDATE
employees
6 columns
employee_idINTEGERnameTEXTdepartmentTEXTmanager_idINTEGERsalaryREALhire_dateDATE
products, order_items tables
product_id | product_name (only products with no order_items rows)
Anti-join: products whose product_id is absent from order_items.
A product is unordered if its id is NOT IN the set of ordered product ids.
Alternatively LEFT JOIN order_items and keep rows where the join is NULL.
Try it yourself first — you learn more from a struggle than a spoiler.
SELECT product_id, product_name
FROM products
WHERE product_id NOT IN (SELECT DISTINCT product_id FROM order_items)
ORDER BY product_id;
customers5 colscustomer_idINTEGERnameTEXTcityTEXTcountryTEXTsignup_dateDATE| customer_id | name | city | country | signup_date |
|---|---|---|---|---|
| 101 | Rahul | Delhi | India | 2023-01-12 |
| 102 | Aman | Mumbai | India | 2023-02-03 |
| 103 | Sara | Bengaluru | India | 2023-02-20 |
products4 colsproduct_idINTEGERproduct_nameTEXTcategoryTEXTpriceREAL| product_id | product_name | category | price |
|---|---|---|---|
| 1 | Wireless Mouse | Electronics | 799 |
| 2 | Office Chair | Furniture | 5499 |
| 3 | Notebook | Stationery | 149 |
orders5 colsorder_idINTEGERcustomer_idINTEGERorder_dateDATEamountREALstatusTEXT| order_id | customer_id | order_date | amount | status |
|---|---|---|---|---|
| 1001 | 101 | 2024-01-05 | 1598 | Delivered |
| 1002 | 102 | 2024-01-11 | 5499 | Delivered |
| 1003 | 101 | 2024-02-02 | 149 | Cancelled |
order_items4 colsorder_idINTEGERproduct_idINTEGERquantityINTEGERunit_priceREAL| order_id | product_id | quantity | unit_price |
|---|---|---|---|
| 1001 | 1 | 2 | 799 |
| 1002 | 2 | 1 | 5499 |
| 1004 | 3 | 5 | 149 |
payments5 colspayment_idINTEGERorder_idINTEGERmethodTEXTamountREALpaid_dateDATE| payment_id | order_id | method | amount | paid_date |
|---|---|---|---|---|
| 5001 | 1001 | UPI | 1598 | 2024-01-05 |
| 5002 | 1002 | Card | 5499 | 2024-01-11 |
| 5003 | 1005 | UPI | 999 | 2024-03-02 |
employees6 colsemployee_idINTEGERnameTEXTdepartmentTEXTmanager_idINTEGERsalaryREALhire_dateDATE| employee_id | name | department | manager_id | salary | hire_date |
|---|---|---|---|---|---|
| 1 | Meera | Analytics | NULL | 180000 | |
| 2 | Rohit | Analytics | 1 | 95000 | |
| 3 | Neha | Engineering | 1 | 120000 |