Question
Table name: Products
Column Name | Type |
---|---|
product_id | int |
low_fats | enum |
recyclable | enum |
product_id
is the primary key (column with unique values) for this table.
low_fats
is an ENUM
of type (Y
, N
) where Y
means this product is low fat and N
means it is not.
recyclable
is an ENUM
of types (Y
, N
) where Y
means this product is recyclable and N
means it is not.
Write a solution to find the ids of products that are both low fat and recyclable.
Return the result table in any order.
Explaination
This is one the most basic SQL SELECT
query scenario,
by using SELECT <column_name> FROM <table_name> WHERE <conditions>
you may get the solution easily.
Solution
SELECT product_id FROM Products WHERE low_fats = "Y" AND recyclable = "Y";
More SQL 50 questions: here
Please cite the source for reprints, feel free to verify the sources cited in the article, and point out any errors or lack of clarity of expression. You can comment in the comments section below or email to GreenMeeple@yahoo.com