Answer:
See explanation
Explanation:
The complete question is
Write a SELECT statement that returns the same result set as this SELECT statement, but don't use a
join. Instead, use a subquery in a WHERE clause that uses the IN keyword.
SELECT DISTINCT category_name
FROM categories c JOIN products p
ON c.category_id = p.category_id
ORDER BY category_name
The join clause gives us all the registers of both tables, for which the category_id of categories coincides to the category_id in the table products. That is, we can first select the distinct category_id's from products and the see the categories from categories table, whose id is in that list. That means writing the following query:
Select distinct category_name
from categories c
where c.category_id in (
select distinct p.category_id
from products p)
order by category_name