File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ Problem description:
3+
4+ +-------------+---------+
5+ | Column Name | Type |
6+ +-------------+---------+
7+ | product_id | int |
8+ | low_fats | enum |
9+ | recyclable | enum |
10+ +-------------+---------+
11+ product_id is the primary key for this table.
12+ low_fats is an ENUM of type ('Y', 'N') where 'Y' means this product is low fat and 'N' means it is not.
13+ recyclable is an ENUM of types ('Y', 'N') where 'Y' means this product is recyclable and 'N' means it is not.
14+
15+ Write an SQL query to find the ids of products that are both low fat and recyclable.
16+
17+ Return the result table in any order.
18+
19+ The query result format is in the following example.
20+ */
21+
22+ /*
23+ Example 1:
24+
25+ Input:
26+ Products table:
27+ +-------------+----------+------------+
28+ | product_id | low_fats | recyclable |
29+ +-------------+----------+------------+
30+ | 0 | Y | N |
31+ | 1 | Y | Y |
32+ | 2 | N | Y |
33+ | 3 | Y | Y |
34+ | 4 | N | N |
35+ +-------------+----------+------------+
36+ Output:
37+ +-------------+
38+ | product_id |
39+ +-------------+
40+ | 1 |
41+ | 3 |
42+ +-------------+
43+ Explanation: Only products 1 and 3 are both low fat and recyclable.
44+ */
45+
46+ # Write your MySQL query statement below
47+
48+ SELECT product_id FROM Products WHERE low_fats = 'Y' AND recyclable = 'Y'
You can’t perform that action at this time.
0 commit comments