Skip to main content

SQL 练习 Select statement

https://leetcode.cn/studyplan/sql-free-50/

1757. Recyclable and Low Fat Products

enum equal comparision

# Write your MySQL query statement below
SELECT product_id
FROM Products
WHERE low_fats = "Y" and recyclable = "Y"

584. Find Customer Refere

is null

# Write your MySQL query statement below
SELECT name
FROM Customer
WHERE referee_id != 2 or referee_id is null;

595. Big Countries

>=

# Write your MySQL query statement below
SELECT name, population, area
FROM World
WHERE area >= 3000000 or population >= 25000000

1148. Article Views I

  • disctinct
  • as id
  • ORDER BY 1 ASC
# Write your MySQL query statement below
SELECT distinct(author_id) as id
FROM Views
WHERE author_id = viewer_id
ORDER BY 1 ASC

1683. Invalid Tweets

# Write your MySQL query statement below
SELECT tweet_id
FROM Tweets
WHERE length(content) > 15