高频SQL50题

LeetCode高频SQL 50题

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

查询

1757. 可回收且低脂的产品

# Write your MySQL query statement below
select product_id from Products
where low_fats = 'Y'
and recyclable = 'Y';

584. 寻找用户推荐人

# Write your MySQL query statement below
select name from Customer
where ifnull(referee_id,0) != 2;

595. 大的国家

# Write your MySQL query statement below
select name , population, area
from World
where area >= 3000000
or population >= 25000000 ;

1148. 文章浏览 I

# Write your MySQL query statement below
select distinct author_id as id
from Views
where author_id = viewer_id
order by id asc;

1683. 无效的推文

# Write your MySQL query statement below
select tweet_id from Tweets
where length(content) > 15;

连接